Skip to content

Commit c2db7eb

Browse files
authored
Merge pull request #2428 from SnoopJ/bugfix/gh2348_cautious-DNS-resolution
url: Wrap DNS resolution in try/except
2 parents 1fe5e2f + a37f88a commit c2db7eb

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

sopel/modules/url.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,18 @@ def process_urls(
406406
try:
407407
ips = [ip_address(parsed_url.hostname)]
408408
except ValueError:
409-
ips = [ip_address(ip) for ip in dns.resolver.resolve(parsed_url.hostname)]
409+
# Extra try/except here in case the DNS resolution fails, see #2348
410+
try:
411+
ips = [ip_address(ip) for ip in dns.resolver.resolve(parsed_url.hostname)]
412+
except Exception as exc:
413+
LOGGER.debug(
414+
"Cannot resolve hostname %s, ignoring URL %s"
415+
" (exception was: %r)",
416+
parsed_url.hostname,
417+
url,
418+
exc,
419+
)
420+
continue
410421

411422
private = False
412423
for ip in ips:

0 commit comments

Comments
 (0)