discovery/dns/dns.go: fix handling of truncated dns records
goes into the detail, but more or
less the existing solution was no longer supported and needed to be
rewritten to support the new versions of the library. miekg additionally
claims this is more correct in the ticket.
@@ -317,7 +317,11 @@ func askServerForName(name string, queryType uint16, client *dns.Client, servAdd
}
response, _, err := client.Exchange(msg, servAddr)
- if err == dns.ErrTruncated {
+ if err != nil {
+ return nil, err
+ }
+
+ if response.Truncated {
if client.Net == "tcp" {
return nil, fmt.Errorf("got truncated message on TCP (64kiB limit exceeded?)")
}
@@ -325,11 +329,6 @@ func askServerForName(name string, queryType uint16, client *dns.Client, servAdd
client.Net = "tcp"
return askServerForName(name, queryType, client, servAddr, false)
}
- if err != nil {
- return nil, err
- }
- if msg.Id != response.Id {
- return nil, fmt.Errorf("DNS ID mismatch, request: %d, response: %d", msg.Id, response.Id)
- }
+
return response, nil
}
