diff --git a/agent/dns_test.go b/agent/dns_test.go index 00ba064569..d42abbeb7a 100644 --- a/agent/dns_test.go +++ b/agent/dns_test.go @@ -130,6 +130,38 @@ func TestEncodeKVasRFC1464(t *testing.T) { } } +func TestDNS_Over_TCP(t *testing.T) { + t.Parallel() + a := NewTestAgent(t.Name(), "") + defer a.Shutdown() + + // Register node + args := &structs.RegisterRequest{ + Datacenter: "dc1", + Node: "Foo", + Address: "127.0.0.1", + } + + var out struct{} + if err := a.RPC("Catalog.Register", args, &out); err != nil { + t.Fatalf("err: %v", err) + } + + m := new(dns.Msg) + m.SetQuestion("foo.node.dc1.consul.", dns.TypeANY) + + c := new(dns.Client) + c.Net = "tcp" + in, _, err := c.Exchange(m, a.DNSAddr()) + if err != nil { + t.Fatalf("err: %v", err) + } + + if len(in.Answer) != 1 { + t.Fatalf("empty lookup: %#v", in) + } +} + func TestDNS_NodeLookup(t *testing.T) { t.Parallel() a := NewTestAgent(t.Name(), "") diff --git a/vendor/github.com/miekg/dns/server.go b/vendor/github.com/miekg/dns/server.go index e18068e2f2..ac5cd04b7e 100644 --- a/vendor/github.com/miekg/dns/server.go +++ b/vendor/github.com/miekg/dns/server.go @@ -495,6 +495,7 @@ func (srv *Server) serveTCP(l net.Listener) error { rw.Close() return } + srv.inFlight.Add(1) srv.serve(rw.RemoteAddr(), handler, m, nil, nil, rw) }()