|
|
@ -1925,34 +1925,42 @@ func TestDNS_PreparedQueryNearIP(t *testing.T) {
|
|
|
|
err := a.RPC("PreparedQuery.Apply", args, &id)
|
|
|
|
err := a.RPC("PreparedQuery.Apply", args, &id)
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.NoError(t, err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
retry.Run(t, func(r *retry.R) {
|
|
|
|
|
|
|
|
m :=new(dns.Msg)
|
|
|
|
|
|
|
|
m.SetQuestion("some.query.we.like.query.consul.", dns.TypeA)
|
|
|
|
|
|
|
|
m.SetEdns0(4096, false)
|
|
|
|
|
|
|
|
o := new(dns.OPT)
|
|
|
|
|
|
|
|
o.Hdr.Name = "."
|
|
|
|
|
|
|
|
o.Hdr.Rrtype = dns.TypeOPT
|
|
|
|
|
|
|
|
e := new(dns.EDNS0_SUBNET)
|
|
|
|
|
|
|
|
e.Code = dns.EDNS0SUBNET
|
|
|
|
|
|
|
|
e.Family = 1
|
|
|
|
|
|
|
|
e.SourceNetmask = 32
|
|
|
|
|
|
|
|
e.SourceScope = 0
|
|
|
|
|
|
|
|
e.Address = net.ParseIP("198.18.0.9").To4()
|
|
|
|
|
|
|
|
o.Option = append(o.Option, e)
|
|
|
|
|
|
|
|
m.Extra = append(m.Extra, o)
|
|
|
|
|
|
|
|
|
|
|
|
m :=new(dns.Msg)
|
|
|
|
c := new(dns.Client)
|
|
|
|
m.SetQuestion("some.query.we.like.query.consul.", dns.TypeA)
|
|
|
|
in, _, err := c.Exchange(m, a.DNSAddr())
|
|
|
|
m.SetEdns0(4096, false)
|
|
|
|
if err != nil {
|
|
|
|
o := new(dns.OPT)
|
|
|
|
r.Fatalf("Error with call to dns.Client.Exchange: %s", err)
|
|
|
|
o.Hdr.Name = "."
|
|
|
|
}
|
|
|
|
o.Hdr.Rrtype = dns.TypeOPT
|
|
|
|
|
|
|
|
e := new(dns.EDNS0_SUBNET)
|
|
|
|
|
|
|
|
e.Code = dns.EDNS0SUBNET
|
|
|
|
|
|
|
|
e.Family = 1
|
|
|
|
|
|
|
|
e.SourceNetmask = 32
|
|
|
|
|
|
|
|
e.SourceScope = 0
|
|
|
|
|
|
|
|
e.Address = net.ParseIP("198.18.0.9").To4()
|
|
|
|
|
|
|
|
o.Option = append(o.Option, e)
|
|
|
|
|
|
|
|
m.Extra = append(m.Extra, o)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
c := new(dns.Client)
|
|
|
|
|
|
|
|
in, _, err := c.Exchange(m, a.DNSAddr())
|
|
|
|
|
|
|
|
require.NoErrorf(t, err, "Error with call to dns.Client.Exchange: %s", err)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
require.Equalf(t, len(serviceNodes), len(in.Answer), "Expecting %d A RRs in response, Actual found was %d", len(serviceNodes), len(in.Answer))
|
|
|
|
if len(serviceNodes) != len(in.Answer) {
|
|
|
|
|
|
|
|
r.Fatalf("Expecting %d A RRs in response, Actual found was %d", len(serviceNodes), len(in.Answer))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for i, rr := range in.Answer {
|
|
|
|
for i, rr := range in.Answer {
|
|
|
|
aRec, ok := rr.(*dns.A);
|
|
|
|
if aRec, ok := rr.(*dns.A); ok {
|
|
|
|
require.Truef(t, ok, "DNS Answer contained a non A RR")
|
|
|
|
if actual := aRec.A.String(); serviceNodes[i].address != actual {
|
|
|
|
actual := aRec.A.String()
|
|
|
|
r.Fatalf("Expecting A RR #%d = %s, Actual RR was %s", i, serviceNodes[i].address, actual)
|
|
|
|
require.Equalf(t, serviceNodes[i].address, actual, "Expecting A RR #%d = %s, Actual RR was %s", i, serviceNodes[i].address, actual)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
r.Fatalf("DNS Answer container a non-A RR")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestDNS_ServiceLookup_PreparedQueryNamePeriod(t *testing.T) {
|
|
|
|
func TestDNS_ServiceLookup_PreparedQueryNamePeriod(t *testing.T) {
|
|
|
|