Skip to content

Commit

Permalink
Remove dnspython depreciation warning
Browse files Browse the repository at this point in the history
Where previously we used dns.resolver.query(), switch to d.r.resolve()

Complete compatibility would require d.r.resolve(search=True) but this works without it so far.

Perhaps see also rthalley/dnspython#581
  • Loading branch information
tripleee committed Nov 12, 2020
1 parent 1e8880d commit de73887
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions blacklists.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,12 @@ def item_check(ns):
if item.get('disable', None):
return False
try:
addr = dns.resolver.query(ns, 'a')
addr = dns.resolver.resolve(ns, 'a')
log('debug', '{0} resolved to {1}'.format(
ns, ','.join(x.to_text() for x in addr)))
except (dns.resolver.NXDOMAIN, dns.resolver.NoAnswer):
if not item.get('pass', None):
soa = dns.resolver.query(ns, 'soa')
soa = dns.resolver.resolve(ns, 'soa')
log('debug', '{0} has no A record; SOA is {1}'.format(
ns, ';'.join(s.to_text() for s in soa)))
except dns.resolver.NoNameservers:
Expand Down
4 changes: 3 additions & 1 deletion findspam.py
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,9 @@ def dns_query(label, qtype):
return DNS_CACHE[(label, qtype)]['result']
try:
starttime = datetime.utcnow()
answer = dns.resolver.query(label, qtype)
# Switched from dns.resolver.query
# See also https://github.com/rthalley/dnspython/issues/581
answer = dns.resolver.resolve(label, qtype)
except dns.exception.DNSException as exc:
if str(exc).startswith('None of DNS query names exist:'):
log('debug', 'DNS label {0} not found; skipping'.format(label))
Expand Down

0 comments on commit de73887

Please sign in to comment.