Retry dns queries with TCP if UDP has an i/o timeout
Signed-off-by: Kelly Campbell <kelly.a.campbell@gmail.com>
This commit is contained in:
parent
e0691e5827
commit
a90e833c3b
@ -144,7 +144,9 @@ func dnsQuery(fqdn string, rtype uint16, nameservers []string, recursive bool) (
|
||||
udp := &dns.Client{Net: "udp", Timeout: DNSTimeout}
|
||||
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}
|
||||
// If the TCP request succeeds, the err will reset to nil
|
||||
in, _, err = tcp.Exchange(m, ns)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user