author | Alberto Bertogli
<albertito@blitiri.com.ar> 2018-07-16 21:53:13 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2018-07-16 21:53:13 UTC |
parent | 82389c3236487101ef4489c34b6c7bc9a925914e |
internal/dnsserver/server.go | +10 | -10 |
diff --git a/internal/dnsserver/server.go b/internal/dnsserver/server.go index d8f13de..76b2b8b 100644 --- a/internal/dnsserver/server.go +++ b/internal/dnsserver/server.go @@ -186,16 +186,16 @@ func (s *Server) classicServe() { func (s *Server) systemdServe() { // We will usually have at least one TCP socket and one UDP socket. // PacketConns are UDP sockets, Listeners are TCP sockets. - // To make things more annoying, both can (and usually will) have nil - // entries for the file descriptors that don't match. - pconns, err := activation.PacketConns(false) - if err != nil { - log.Fatalf("Error getting systemd packet conns: %v", err) - } - - listeners, err := activation.Listeners(false) - if err != nil { - log.Fatalf("Error getting systemd listeners: %v", err) + pconns := []net.PacketConn{} + listeners := []net.Listener{} + for _, f := range activation.Files(true) { + if lis, err := net.FileListener(f); err == nil { + listeners = append(listeners, lis) + f.Close() + } else if pc, err := net.FilePacketConn(f); err == nil { + pconns = append(pconns, pc) + f.Close() + } } var wg sync.WaitGroup