Skip to content

Commit

Permalink
Merge pull request #28 from initstring/dev
Browse files Browse the repository at this point in the history
DNS timeout handling, closing thread pools.
  • Loading branch information
initstring authored Apr 6, 2020
2 parents 76db605 + 1116b38 commit 306013b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions enum_tools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def dns_lookup(nameserver, name):
by the fast_dns_lookup function.
"""
res = dns.resolver.Resolver()
res.timeout = 10
res.nameservers = [nameserver]

try:
Expand All @@ -115,6 +116,9 @@ def dns_lookup(nameserver, name):
return name
except dns.resolver.NXDOMAIN:
return ''
except dns.exception.Timeout:
print(" [!] DNS Timeut on {}. Investigate if there are many"
" of these.".format(name))

def fast_dns_lookup(names, nameserver, callback='', threads=5):
"""
Expand Down Expand Up @@ -151,6 +155,7 @@ def fast_dns_lookup(names, nameserver, callback='', threads=5):
sys.stdout.flush()
sys.stdout.write(" {}/{} complete...".format(current, total))
sys.stdout.write('\r')
pool.close()

# Clear the status message
sys.stdout.write(' \r')
Expand Down

0 comments on commit 306013b

Please sign in to comment.