commit ac15aa2cf1c11cbf8a72bdc00a2adc547c2a4b36 from: Aleksey Ryndin date: Tue Nov 05 09:07:39 2024 UTC Add: expired token processing commit - 4bf100ffe6f78906da257552cdf0dabbb69758e1 commit + ac15aa2cf1c11cbf8a72bdc00a2adc547c2a4b36 blob - 4e71bf2d6bbd5ef44e9012b2d2a3a79be27b6f70 blob + 26e215cdccfbe4ca41b3d00754dc93fbb4b1ea61 --- lonk.py +++ lonk.py @@ -587,7 +587,7 @@ def new_client_stage_3_ask_password(cert_hash, lonk_ur db_con = db_connect() with db_con: db_con.execute( - "INSERT INTO client (cert_hash, honk_url, token) VALUES (?, ?, ?)", + "INSERT INTO client (cert_hash, honk_url, token) VALUES (?, ?, ?) ON CONFLICT REPLACE", (cert_hash, honk_url, token) ) print(f'30 {lonk_url.build([])}\r') @@ -663,7 +663,19 @@ def main(): stderr.write(f"{cert_hash_}|{input_url}|{clock_gettime(CLOCK_MONOTONIC) - start_time:.3f}sec.\n") except HTTPError as error: stderr.write(f"{error}\n") - print(f"43 Remote server return {error.code}: {error.reason}\r") + if error.code == 403: + print("20 text/gemini\r") + print(f"# 𝓗 onk\r") + print("\r") + print(f"Remote server return {error.code}:\r") + print("```\r") + print(f"{error.reason}\r") + print("```\r") + print("\r") + print("The previously issued token has probably expired. You need to authenticate again:\r") + print(f'=> {lonk_url.build("ask_server")}\r') + else: + print(f"43 Remote server return {error.code}: {error.reason}\r") except URLError as error: stderr.write(f"{error}\n") print(f"43 Error while trying to access remote server: {error.reason}\r")