Skip to content

Commit 306013b

Browse files
authored
Merge pull request #28 from initstring/dev
DNS timeout handling, closing thread pools.
2 parents 76db605 + 1116b38 commit 306013b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

enum_tools/utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ def dns_lookup(nameserver, name):
107107
by the fast_dns_lookup function.
108108
"""
109109
res = dns.resolver.Resolver()
110+
res.timeout = 10
110111
res.nameservers = [nameserver]
111112

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

119123
def fast_dns_lookup(names, nameserver, callback='', threads=5):
120124
"""
@@ -151,6 +155,7 @@ def fast_dns_lookup(names, nameserver, callback='', threads=5):
151155
sys.stdout.flush()
152156
sys.stdout.write(" {}/{} complete...".format(current, total))
153157
sys.stdout.write('\r')
158+
pool.close()
154159

155160
# Clear the status message
156161
sys.stdout.write(' \r')

0 commit comments

Comments
 (0)