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-05-31 19:58:33 +02:00
|
|
|
listeners, err := activation.Listeners()
|
2018-01-25 10:24:28 +01:00
|
|
|
if err == nil && len(listeners) > 0 {
|
2018-01-24 15:14:48 +01:00
|
|
|
for i, listener := range listeners {
|
2018-01-25 10:24:28 +01:00
|
|
|
if listener != nil {
|
|
|
|
dlog.Noticef("Wiring systemd TCP socket #%d", i)
|
|
|
|
go proxy.tcpListener(listener.(*net.TCPListener))
|
|
|
|
}
|
2018-01-24 15:14:48 +01:00
|
|
|
}
|
|
|
|
}
|
2018-05-31 19:58:33 +02:00
|
|
|
packetConns, err := activation.PacketConns()
|
2018-01-25 10:24:28 +01:00
|
|
|
if err == nil && len(packetConns) > 0 {
|
2018-01-24 15:14:48 +01:00
|
|
|
for i, packetConn := range packetConns {
|
2018-01-25 10:24:28 +01:00
|
|
|
if packetConn != nil {
|
|
|
|
dlog.Noticef("Wiring systemd UDP socket #%d", i)
|
|
|
|
go proxy.udpListener(packetConn.(*net.UDPConn))
|
|
|
|
}
|
2018-01-24 15:14:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func SystemDNotify() {
|
|
|
|
daemon.SdNotify(false, "READY=1")
|
|
|
|
}
|