Fix systemd socket connections (#492)

Upstream systemd go library broke use of TCP and UDP sockets at the same time.
Changed to use lower level API to work around this. Also improved logging of
systemd socket connections to include systemd unit file name and address.
This commit is contained in:
dwimmer 2018-06-13 09:49:32 -05:00 committed by Frank Denis
parent 600b6c0f60
commit b498e6655e
1 changed files with 11 additions and 16 deletions

View File

@ -9,24 +9,19 @@ import (
)
func (proxy *Proxy) SystemDListeners() error {
listeners, err := activation.Listeners()
if err == nil && len(listeners) > 0 {
for i, listener := range listeners {
if listener != nil {
dlog.Noticef("Wiring systemd TCP socket #%d", i)
go proxy.tcpListener(listener.(*net.TCPListener))
}
}
}
packetConns, err := activation.PacketConns()
if err == nil && len(packetConns) > 0 {
for i, packetConn := range packetConns {
if packetConn != nil {
dlog.Noticef("Wiring systemd UDP socket #%d", i)
go proxy.udpListener(packetConn.(*net.UDPConn))
}
files := activation.Files(true)
for i, file := range files {
if listener, err := net.FileListener(file); err == nil {
dlog.Noticef("Wiring systemd TCP socket #%d, %s, %s", i, file.Name(), listener.Addr())
go proxy.tcpListener(listener.(*net.TCPListener))
} else if pc, err := net.FilePacketConn(file); err == nil {
dlog.Noticef("Wiring systemd UDP socket #%d, %s, %s", i, file.Name(), pc.LocalAddr())
go proxy.udpListener(pc.(*net.UDPConn))
}
file.Close()
}
return nil
}