diff options
| author | Zach DeCook <zachdecook@librem.one> | 2021-02-07 23:32:24 -0500 |
|---|---|---|
| committer | Zach DeCook <zachdecook@librem.one> | 2021-02-07 23:32:24 -0500 |
| commit | 6da92c8e58bda9976ca2693d5e9bf25ac2b9cb46 (patch) | |
| tree | ff310c955d1c6c13f9aec46e001a72a61c06b31f /zachwalk.py | |
| parent | 6ae010283fa78e7b4be3e63cc0a27d6b3447bbad (diff) | |
| download | zachwalk-6da92c8e58bda9976ca2693d5e9bf25ac2b9cb46.tar.gz | |
connection: timeout after 2 seconds
Diffstat (limited to 'zachwalk.py')
| -rwxr-xr-x | zachwalk.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/zachwalk.py b/zachwalk.py index 2c2c3ea..a7d1a8d 100755 --- a/zachwalk.py +++ b/zachwalk.py @@ -12,13 +12,15 @@ def getnewestdate(url): """load the url, and find the newest date listed in a link""" # TODO: outsource to pre-installed cli program? hostname = url.split('/')[2] - s = socket.create_connection((hostname, 1965)) + try: + s = socket.create_connection((hostname, 1965),timeout=2) + except: + return DEFAULT context = ssl.SSLContext() context.check_hostname = False context.verify_mode = ssl.CERT_NONE s = context.wrap_socket(s, server_hostname = hostname) s.sendall((url + '\r\n').encode("UTF-8")) - # Get header and check for redirects fp = s.makefile("rb") header = fp.readline() header = header.decode("UTF-8").strip() |
