Added possibility to use TLS with systemd socket activation

Signed-off-by: kayrus <kay.diam@gmail.com>
This commit is contained in:
kayrus 2015-11-03 11:03:35 +01:00
parent 0a6acbede3
commit 0f2b3191d9
2 changed files with 13 additions and 4 deletions

View file

@ -3,6 +3,7 @@
package server package server
import ( import (
"crypto/tls"
"fmt" "fmt"
"net" "net"
"net/http" "net/http"
@ -24,7 +25,7 @@ func (s *Server) newServer(proto, addr string) ([]*HTTPServer, error) {
) )
switch proto { switch proto {
case "fd": case "fd":
ls, err = listenFD(addr) ls, err = listenFD(addr, s.cfg.TLSConfig)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -84,9 +85,17 @@ func allocateDaemonPort(addr string) error {
// listenFD returns the specified socket activated files as a slice of // listenFD returns the specified socket activated files as a slice of
// net.Listeners or all of the activated files if "*" is given. // net.Listeners or all of the activated files if "*" is given.
func listenFD(addr string) ([]net.Listener, error) { func listenFD(addr string, tlsConfig *tls.Config) ([]net.Listener, error) {
var (
err error
listeners []net.Listener
)
// socket activation // socket activation
listeners, err := systemdActivation.Listeners(false) if tlsConfig != nil {
listeners, err = systemdActivation.TLSListeners(false, tlsConfig)
} else {
listeners, err = systemdActivation.Listeners(false)
}
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -49,7 +49,7 @@ clone git github.com/agl/ed25519 d2b94fd789ea21d12fac1a4443dd3a3f79cda72c
clone git github.com/opencontainers/runc 6c198ae2d065c37f44316e0de3df7f3b88950923 # libcontainer clone git github.com/opencontainers/runc 6c198ae2d065c37f44316e0de3df7f3b88950923 # libcontainer
# libcontainer deps (see src/github.com/opencontainers/runc/Godeps/Godeps.json) # libcontainer deps (see src/github.com/opencontainers/runc/Godeps/Godeps.json)
clone git github.com/coreos/go-systemd db045881d426f46e064766fa9f546c3006d0973e clone git github.com/coreos/go-systemd v4
clone git github.com/godbus/dbus v2 clone git github.com/godbus/dbus v2
clone git github.com/syndtr/gocapability 66ef2aa7a23ba682594e2b6f74cf40c0692b49fb clone git github.com/syndtr/gocapability 66ef2aa7a23ba682594e2b6f74cf40c0692b49fb
clone git github.com/golang/protobuf 655cdfa588ea clone git github.com/golang/protobuf 655cdfa588ea