mirror of https://github.com/status-im/consul.git
Fixes a panic on TCP-based DNS lookups.
This came in via the monkey patch in #3861. Fixes #3877
This commit is contained in:
parent
94ea08d066
commit
3724e49ddf
|
@ -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(), "")
|
||||
|
|
|
@ -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)
|
||||
}()
|
||||
|
||||
|
|
Loading…
Reference in New Issue