dnscrypt-proxy/dnscrypt-proxy/systemd_linux.go

36 lines
802 B
Go
Raw Normal View History

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 {
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-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 {
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))
}
}
}
return nil
}
func SystemDNotify() {
daemon.SdNotify(false, "READY=1")
}