@@ -168,30 +168,34 @@ def dns_lookup(nameserver, name):
168168 nameserverfile = nameserver
169169
170170 res = dns .resolver .Resolver ()
171- res .timeout = 10
171+ res .timeout = 3
172172 if nameserverfile :
173173 nameservers = read_nameservers (nameserverfile )
174174 res .nameservers = nameservers
175175 else :
176176 res .nameservers = [nameserver ]
177177
178- try :
179- res .query (name )
180- # If no exception is thrown, return the valid name
181- return name
182- except dns .resolver .NXDOMAIN :
183- return ''
184- except dns .resolver .NoNameservers as exc_text :
185- print (" [!] Error querying nameservers! This could be a problem." )
186- print (" [!] If you're using a VPN, try setting --ns to your VPN's nameserver." )
187- print (" [!] Bailing because you need to fix this" )
188- print (" [!] More Info:" )
189- print (exc_text )
190- return '-#BREAKOUT_DNS_ERROR#-'
191- except dns .exception .Timeout :
192- print (f" [!] DNS Timeout on { name } . Investigate if there are many"
193- " of these." )
194- return ''
178+ tries = 0
179+
180+ while tries < 3 :
181+ try :
182+ res .query (name )
183+ # If no exception is thrown, return the valid name
184+ return name
185+ except dns .resolver .NXDOMAIN :
186+ return ''
187+ except dns .resolver .NoNameservers as exc_text :
188+ print (" [!] Error querying nameservers! This could be a problem." )
189+ print (" [!] If you're using a VPN, try setting --ns to your VPN's nameserver." )
190+ print (" [!] Bailing because you need to fix this" )
191+ print (" [!] More Info:" )
192+ print (exc_text )
193+ return '-#BREAKOUT_DNS_ERROR#-'
194+ except dns .exception .Timeout :
195+ tries += 1
196+
197+ print (f" [!] DNS lookup for { name } timed out after 3 tries. Investigate if there are many of these." )
198+ return ''
195199
196200
197201def fast_dns_lookup (names , nameserver , nameserverfile , callback = '' , threads = 5 ):
0 commit comments