From a908184e0700963964e7d1e192541c4448db8fc9 Mon Sep 17 00:00:00 2001 From: James Gerity Date: Mon, 20 Mar 2023 10:19:16 -0400 Subject: [PATCH] Wrap DNS resolution in try/except (closes #2348) --- sopel/modules/url.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sopel/modules/url.py b/sopel/modules/url.py index 47087c2248..a30a869a1a 100644 --- a/sopel/modules/url.py +++ b/sopel/modules/url.py @@ -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: