diff options
Diffstat (limited to 'plugin/pkg/dnstest/server.go')
-rw-r--r-- | plugin/pkg/dnstest/server.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/plugin/pkg/dnstest/server.go b/plugin/pkg/dnstest/server.go index 72437cf8b..8e9a2c76a 100644 --- a/plugin/pkg/dnstest/server.go +++ b/plugin/pkg/dnstest/server.go @@ -23,8 +23,15 @@ func NewServer(f dns.HandlerFunc) *Server { ch1 := make(chan bool) ch2 := make(chan bool) - p, _ := net.ListenPacket("udp", ":0") - l, _ := net.Listen("tcp", p.LocalAddr().String()) + l, _ := net.Listen("tcp", ":0") + if l == nil { + return nil + } + p, _ := net.ListenPacket("udp", l.Addr().String()) + if p == nil { + l.Close() + return nil // yes, this may crash some test, but this is better than hanging + } s1 := &dns.Server{PacketConn: p} s2 := &dns.Server{Listener: l} |