Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

url: Wrap DNS resolution in try/except #2428

Merged
merged 1 commit into from
Mar 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion sopel/modules/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,18 @@ 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 Exception as exc:
LOGGER.debug(
"Cannot resolve hostname %s, ignoring URL %s"
" (exception was: %r)",
parsed_url.hostname,
url,
exc,
)
continue

private = False
for ip in ips:
Expand Down