|
|
@ -2800,28 +2800,31 @@ func TestDNS_TCP_and_UDP_Truncate(t *testing.T) {
|
|
|
|
for _, qType := range []uint16{dns.TypeANY, dns.TypeA, dns.TypeSRV} {
|
|
|
|
for _, qType := range []uint16{dns.TypeANY, dns.TypeA, dns.TypeSRV} {
|
|
|
|
for _, question := range questions {
|
|
|
|
for _, question := range questions {
|
|
|
|
for _, protocol := range protocols {
|
|
|
|
for _, protocol := range protocols {
|
|
|
|
t.Run(fmt.Sprintf("lookup %s %s (qType:=%d)", question, protocol, qType), func(t *testing.T) {
|
|
|
|
for _, compress := range []bool{true, false} {
|
|
|
|
m := new(dns.Msg)
|
|
|
|
t.Run(fmt.Sprintf("lookup %s %s (qType:=%d) compressed=%b", question, protocol, qType, compress), func(t *testing.T) {
|
|
|
|
m.SetQuestion(question, dns.TypeANY)
|
|
|
|
m := new(dns.Msg)
|
|
|
|
if protocol == "udp" {
|
|
|
|
m.SetQuestion(question, dns.TypeANY)
|
|
|
|
m.SetEdns0(8192, true)
|
|
|
|
if protocol == "udp" {
|
|
|
|
}
|
|
|
|
m.SetEdns0(8192, true)
|
|
|
|
c := new(dns.Client)
|
|
|
|
}
|
|
|
|
c.Net = protocol
|
|
|
|
c := new(dns.Client)
|
|
|
|
in, out, err := c.Exchange(m, a.DNSAddr())
|
|
|
|
c.Net = protocol
|
|
|
|
if err != nil && err != dns.ErrTruncated {
|
|
|
|
m.Compress = compress
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
in, out, err := c.Exchange(m, a.DNSAddr())
|
|
|
|
}
|
|
|
|
if err != nil && err != dns.ErrTruncated {
|
|
|
|
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
// Check for the truncate bit
|
|
|
|
}
|
|
|
|
shouldBeTruncated := numServices > 4095
|
|
|
|
|
|
|
|
|
|
|
|
// Check for the truncate bit
|
|
|
|
if shouldBeTruncated != in.Truncated {
|
|
|
|
shouldBeTruncated := numServices > 4095
|
|
|
|
info := fmt.Sprintf("service %s question:=%s (%s) (%d total records) in %v",
|
|
|
|
|
|
|
|
service, question, protocol, numServices, out)
|
|
|
|
if shouldBeTruncated != in.Truncated {
|
|
|
|
t.Fatalf("Should have truncate:=%v for %s", shouldBeTruncated, info)
|
|
|
|
info := fmt.Sprintf("service %s question:=%s (%s) (%d total records) in %v",
|
|
|
|
}
|
|
|
|
service, question, protocol, numServices, out)
|
|
|
|
})
|
|
|
|
t.Fatalf("Should have truncate:=%v for %s", shouldBeTruncated, info)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|