Merge pull request #1111 from kellycampbell/udp-timeout-workaround
Retry dns queries with TCP if UDP has an i/o timeout
This commit is contained in:
commit
670cd8564f
@ -144,7 +144,9 @@ func dnsQuery(fqdn string, rtype uint16, nameservers []string, recursive bool) (
|
|||||||
udp := &dns.Client{Net: "udp", Timeout: DNSTimeout}
|
udp := &dns.Client{Net: "udp", Timeout: DNSTimeout}
|
||||||
in, _, err = udp.Exchange(m, ns)
|
in, _, err = udp.Exchange(m, ns)
|
||||||
|
|
||||||
if err == dns.ErrTruncated {
|
if err == dns.ErrTruncated ||
|
||||||
|
(err != nil && strings.HasPrefix(err.Error(), "read udp") && strings.HasSuffix(err.Error(), "i/o timeout")) {
|
||||||
|
glog.V(6).Infof("UDP dns lookup failed, retrying with TCP: %v", err)
|
||||||
tcp := &dns.Client{Net: "tcp", Timeout: DNSTimeout}
|
tcp := &dns.Client{Net: "tcp", Timeout: DNSTimeout}
|
||||||
// If the TCP request succeeds, the err will reset to nil
|
// If the TCP request succeeds, the err will reset to nil
|
||||||
in, _, err = tcp.Exchange(m, ns)
|
in, _, err = tcp.Exchange(m, ns)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user