Do not retry SERVFAILing nameservers by default
authorBob Halley <halley@dnspython.org>
Sun, 31 Mar 2013 11:28:04 +0000 (12:28 +0100)
committerBob Halley <halley@dnspython.org>
Sun, 31 Mar 2013 11:28:04 +0000 (12:28 +0100)
dns/resolver.py

index f7e8b7adf5dbf3ebdeaf8305592884739d928407..08e86a2819063bb6faca284ec86ef4d27ce034e9 100644 (file)
@@ -433,6 +433,9 @@ class Resolver(object):
     @type flags: int
     @ivar cache: The cache to use.  The default is None.
     @type cache: dns.resolver.Cache object
+    @ivar retry_servfail: should we retry a nameserver if it says SERVFAIL?
+    The default is 'false'.
+    @type retry_servfail: bool
     """
     def __init__(self, filename='/etc/resolv.conf', configure=True):
         """Initialize a resolver instance.
@@ -473,6 +476,7 @@ class Resolver(object):
         self.payload = 0
         self.cache = None
         self.flags = None
+        self.retry_servfail = False
 
     def read_resolv_conf(self, f):
         """Process f as a file in the /etc/resolv.conf format.  If f is
@@ -843,7 +847,7 @@ class Resolver(object):
                     # rcode in it.  Remove the server from the mix if
                     # the rcode isn't SERVFAIL.
                     #
-                    if rcode != dns.rcode.SERVFAIL:
+                    if rcode != dns.rcode.SERVFAIL or not retry_servfail:
                         nameservers.remove(nameserver)
                     response = None
                 if not response is None: