From 04323e1f5c5a1e468c968349481226b2211deb8f Mon Sep 17 00:00:00 2001 From: Zed <124834187+zZedix@users.noreply.github.com> Date: Sun, 5 Oct 2025 01:52:45 +0330 Subject: [PATCH 1/2] Handle socket.gaierror for invalid hostnames --- main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index e3043aa60..3cd4ff8ed 100644 --- a/main.py +++ b/main.py @@ -45,7 +45,7 @@ def check_and_modify_ip(ip_address: str) -> str: Raises: ValueError: If the provided IP address is invalid, return localhost. """ - try: + try: # Attempt to resolve hostname to IP address resolved_ip = socket.gethostbyname(ip_address) @@ -59,7 +59,7 @@ def check_and_modify_ip(ip_address: str) -> str: else: return "localhost" - except ValueError: + except (ValueError, socket.gaierror): return "localhost" From 55e27f4f212c33ac000f267f5c593bd94aeda65d Mon Sep 17 00:00:00 2001 From: Zed <124834187+zZedix@users.noreply.github.com> Date: Sun, 5 Oct 2025 11:26:10 +0330 Subject: [PATCH 2/2] Update main.py --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 3cd4ff8ed..03dd0e69a 100644 --- a/main.py +++ b/main.py @@ -45,7 +45,7 @@ def check_and_modify_ip(ip_address: str) -> str: Raises: ValueError: If the provided IP address is invalid, return localhost. """ - try: + try: # Attempt to resolve hostname to IP address resolved_ip = socket.gethostbyname(ip_address)