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:
parent
600b6c0f60
commit
b498e6655e
|
@ -9,24 +9,19 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (proxy *Proxy) SystemDListeners() error {
|
func (proxy *Proxy) SystemDListeners() error {
|
||||||
listeners, err := activation.Listeners()
|
files := activation.Files(true)
|
||||||
if err == nil && len(listeners) > 0 {
|
|
||||||
for i, listener := range listeners {
|
for i, file := range files {
|
||||||
if listener != nil {
|
if listener, err := net.FileListener(file); err == nil {
|
||||||
dlog.Noticef("Wiring systemd TCP socket #%d", i)
|
dlog.Noticef("Wiring systemd TCP socket #%d, %s, %s", i, file.Name(), listener.Addr())
|
||||||
go proxy.tcpListener(listener.(*net.TCPListener))
|
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))
|
||||||
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))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
file.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue