From e8a0b0a050f8ff8de3f8296707339e6920164f34 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sat, 13 Nov 2021 01:20:13 -0800 Subject: [PATCH] Let get_external_ip take a timeout. --- voussoirkit/networktools.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/voussoirkit/networktools.py b/voussoirkit/networktools.py index 69e6563..a496f7f 100644 --- a/voussoirkit/networktools.py +++ b/voussoirkit/networktools.py @@ -23,9 +23,9 @@ class NetworkToolsException(Exception): class NoInternet(NetworkToolsException): pass -def get_external_ip() -> str: +def get_external_ip(timeout=10) -> str: url = 'https://voussoir.net/whatsmyip' - response = requests.get(url) + response = requests.get(url, timeout=timeout) response.raise_for_status() ip = response.text.strip() return ip