2018-01-24 15:14:48 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net"
|
|
|
|
|
|
|
|
"github.com/coreos/go-systemd/activation"
|
|
|
|
"github.com/coreos/go-systemd/daemon"
|
|
|
|
"github.com/jedisct1/dlog"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (proxy *Proxy) SystemDListeners() error {
|
2018-06-13 16:49:32 +02:00
|
|
|
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))
|
2018-01-24 15:14:48 +01:00
|
|
|
}
|
2018-06-13 16:49:32 +02:00
|
|
|
file.Close()
|
2018-01-24 15:14:48 +01:00
|
|
|
}
|
2018-06-13 16:49:32 +02:00
|
|
|
|
2018-01-24 15:14:48 +01:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func SystemDNotify() {
|
|
|
|
daemon.SdNotify(false, "READY=1")
|
|
|
|
}
|