Browse Source

discovery/dns/dns.go: fix handling of truncated dns records

https://github.com/miekg/dns/pull/815 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.

Signed-off-by: Erik Hollensbe <github@hollensbe.org>
pull/5020/head
Erik Hollensbe 6 years ago
parent
commit
be3c082539
  1. 13
      discovery/dns/dns.go

13
discovery/dns/dns.go

@ -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
}

Loading…
Cancel
Save