Merge pull request #228 from techinz/main

Get IP fix
This commit is contained in:
daijro 2025-03-09 01:39:47 -06:00 committed by GitHub
commit c390b260b5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 4 deletions

1
.gitignore vendored
View file

@ -17,6 +17,7 @@ pythonlib/*.png
scripts/*.png
scripts/test*
.vscode
.idea
/tests/*.disabled
k8s/

View file

@ -100,6 +100,8 @@ def public_ip(proxy: Optional[str] = None) -> str:
"https://ifconfig.co/ip",
"https://ipecho.net/plain",
]
exception = None
for url in URLS:
try:
with _suppress_insecure_warning():
@ -113,8 +115,6 @@ def public_ip(proxy: Optional[str] = None) -> str:
ip = resp.text.strip()
validate_ip(ip)
return ip
except requests.exceptions.ProxyError as e:
raise InvalidProxy(f"Failed to connect to proxy: {proxy}") from e
except (requests.RequestException, InvalidIP):
except (requests.exceptions.ProxyError, requests.RequestException, InvalidIP) as exception:
pass
raise InvalidIP("Failed to get IP address")
raise InvalidIP(f"Failed to get IP address: {exception}")