Skip to content

Commit

Permalink
Wrap DNS resolution in try/except (closes sopel-irc#2348)
Browse files Browse the repository at this point in the history
  • Loading branch information
SnoopJ committed Mar 20, 2023
1 parent 8b098bf commit a908184
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sopel/modules/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,12 @@ def process_urls(
try:
ips = [ip_address(parsed_url.hostname)]
except ValueError:
ips = [ip_address(ip) for ip in dns.resolver.resolve(parsed_url.hostname)]
# Extra try/except here in case the DNS resolution fails, see #2348
try:
ips = [ip_address(ip) for ip in dns.resolver.resolve(parsed_url.hostname)]
except:
LOGGER.debug("Cannot resolve hostname %s, ignoring URL %s", parsed_url.hostname, url, exc_info=True)
continue

private = False
for ip in ips:
Expand Down

0 comments on commit a908184

Please sign in to comment.