Permalink
Browse files

Added set_flags method to dns.resolver.Resolver to allow overriding o…

…f default query flags
  • Loading branch information...
sleach committed Jul 16, 2012
1 parent cdf87c2 commit 588c0eb677acdf96fd7d228f0a016bc110c2c776
Showing with 12 additions and 0 deletions.
  1. +12 −0 dns/resolver.py
View
@@ -425,6 +425,8 @@ class Resolver(object):
@type ednsflags: int
@ivar payload: The EDNS payload size. The default is 0.
@type payload: int
+ @ivar flags: The message flags to use. The default is None (i.e. not overwritten)
+ @type flags: int
@ivar cache: The cache to use. The default is None.
@type cache: dns.resolver.Cache object
"""
@@ -466,6 +468,7 @@ def reset(self):
self.ednsflags = 0
self.payload = 0
self.cache = None
+ self.flags = None
def read_resolv_conf(self, f):
"""Process f as a file in the /etc/resolv.conf format. If f is
@@ -761,6 +764,8 @@ def query(self, qname, rdtype=dns.rdatatype.A, rdclass=dns.rdataclass.IN,
request.use_tsig(self.keyring, self.keyname,
algorithm=self.keyalgorithm)
request.use_edns(self.edns, self.ednsflags, self.payload)
+ if self.flags is not None:
+ request.flags = self.flags
response = None
#
# make a copy of the servers list so we can alter it later.
@@ -898,6 +903,13 @@ def use_edns(self, edns, ednsflags, payload):
self.ednsflags = ednsflags
self.payload = payload
+ def set_flags(self, flags):
+ """Overrides the default flags with your own
+
+ @param flags: The flags to overwrite the default with
+ @type flags: int"""
+ self.flags = flags
+
default_resolver = None
def get_default_resolver():

0 comments on commit 588c0eb

Please sign in to comment.