diff --git a/capsules_to_ignore.txt b/capsules_to_ignore.txt index 09b700e..8618544 100644 --- a/capsules_to_ignore.txt +++ b/capsules_to_ignore.txt @@ -6,3 +6,5 @@ geddit.glv.one geddit.pitr.ca # ignore medusae medusae.space +# ignore some german guy's gemlog +g.dumke.me diff --git a/zenit-reindexer.py b/zenit-reindexer.py index e8bc59e..157ae30 100644 --- a/zenit-reindexer.py +++ b/zenit-reindexer.py @@ -100,6 +100,7 @@ def grab_content(url,redirect_num=0): else: ctx = globals()["ctx"] with socket.socket(socket.AF_INET,socket.SOCK_STREAM) as s: + s.settimeout(5) ss = ctx.wrap_socket(s,server_hostname=parsed.hostname) try: ss.connect((parsed.hostname,parsed.port or 1965)) @@ -107,6 +108,9 @@ def grab_content(url,redirect_num=0): except ConnectionRefusedError: print("Connection refused!",file=sys.stderr) return b'', 'application/octet-stream' + except socket.timeout: + print("Timeout!",file=sys.stderr) + return b'', 'application/octet-stream' except ssl.CertificateError as e: print(e.args[0],file=sys.stderr) return b'', 'application/octet-stream' @@ -141,7 +145,7 @@ def grab_content(url,redirect_num=0): # Return the header with a mimetype of text/plain. If this were a real library I might throw an error here, but this is just to make Zenit work. return header.decode("utf-8"), "text/plain" -CAPSULES_IN_ORBIT = set() +CAPSULES_IN_ORBIT = set(["g.dumke.me"]) # temporary change to remove a certain link import copy links = copy.deepcopy(URLS)[1:] # skip main link diff --git a/zenit.py b/zenit.py index 9ea697d..b07d39a 100644 --- a/zenit.py +++ b/zenit.py @@ -100,6 +100,7 @@ def grab_content(url,redirect_num=0): else: ctx = globals()["ctx"] with socket.socket(socket.AF_INET,socket.SOCK_STREAM) as s: + s.settimeout(5) ss = ctx.wrap_socket(s,server_hostname=parsed.hostname) try: ss.connect((parsed.hostname,parsed.port or 1965)) @@ -107,6 +108,9 @@ def grab_content(url,redirect_num=0): except ConnectionRefusedError: print("Connection refused!") return b'', 'application/octet-stream' + except socket.timeout: + print("Connection refused!") + return b'', 'application/octet-stream' except ssl.CertificateError as e: print(f"Certificate error for domain {parsed.hostname}: {e.args[0]}") return b'', 'application/octet-stream'