Skip to content

Commit

Permalink
Merge pull request rthalley#191 from pspacek/master
Browse files Browse the repository at this point in the history
Add method to force re-read resolv.conf: resolver.reset_default_resolver()
  • Loading branch information
rthalley authored Jul 12, 2016
2 parents 3a503db + 82dba80 commit 5ea9253
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions dns/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1088,12 +1088,20 @@ def set_flags(self, flags):

def get_default_resolver():
"""Get the default resolver, initializing it if necessary."""
global default_resolver
if default_resolver is None:
default_resolver = Resolver()
reset_default_resolver()
return default_resolver


def reset_default_resolver():
"""Re-initialize default resolver.
resolv.conf will be re-read immediatelly.
"""
global default_resolver
default_resolver = Resolver()


def query(qname, rdtype=dns.rdatatype.A, rdclass=dns.rdataclass.IN,
tcp=False, source=None, raise_on_no_answer=True,
source_port=0):
Expand Down

0 comments on commit 5ea9253

Please sign in to comment.