Browse code

Added possibility to use TLS with systemd socket activation

Signed-off-by: kayrus <kay.diam@gmail.com>

kayrus authored on 2015/11/03 19:03:35
Showing 2 changed files
... ...
@@ -3,6 +3,7 @@
3 3
 package server
4 4
 
5 5
 import (
6
+	"crypto/tls"
6 7
 	"fmt"
7 8
 	"net"
8 9
 	"net/http"
... ...
@@ -24,7 +25,7 @@ func (s *Server) newServer(proto, addr string) ([]*HTTPServer, error) {
24 24
 	)
25 25
 	switch proto {
26 26
 	case "fd":
27
-		ls, err = listenFD(addr)
27
+		ls, err = listenFD(addr, s.cfg.TLSConfig)
28 28
 		if err != nil {
29 29
 			return nil, err
30 30
 		}
... ...
@@ -84,9 +85,17 @@ func allocateDaemonPort(addr string) error {
84 84
 
85 85
 // listenFD returns the specified socket activated files as a slice of
86 86
 // net.Listeners or all of the activated files if "*" is given.
87
-func listenFD(addr string) ([]net.Listener, error) {
87
+func listenFD(addr string, tlsConfig *tls.Config) ([]net.Listener, error) {
88
+	var (
89
+		err       error
90
+		listeners []net.Listener
91
+	)
88 92
 	// socket activation
89
-	listeners, err := systemdActivation.Listeners(false)
93
+	if tlsConfig != nil {
94
+		listeners, err = systemdActivation.TLSListeners(false, tlsConfig)
95
+	} else {
96
+		listeners, err = systemdActivation.Listeners(false)
97
+	}
90 98
 	if err != nil {
91 99
 		return nil, err
92 100
 	}
... ...
@@ -49,7 +49,7 @@ clone git github.com/agl/ed25519 d2b94fd789ea21d12fac1a4443dd3a3f79cda72c
49 49
 
50 50
 clone git github.com/opencontainers/runc 6c198ae2d065c37f44316e0de3df7f3b88950923 # libcontainer
51 51
 # libcontainer deps (see src/github.com/opencontainers/runc/Godeps/Godeps.json)
52
-clone git github.com/coreos/go-systemd db045881d426f46e064766fa9f546c3006d0973e
52
+clone git github.com/coreos/go-systemd v4
53 53
 clone git github.com/godbus/dbus v2
54 54
 clone git github.com/syndtr/gocapability 66ef2aa7a23ba682594e2b6f74cf40c0692b49fb
55 55
 clone git github.com/golang/protobuf 655cdfa588ea