mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
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>
This commit is contained in:
parent
9154e9aca8
commit
be3c082539
|
@ -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…
Reference in a new issue