From 5e39136dffe8a447bf1d2ef44fd9de1358d95d68 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Thu, 2 Nov 2023 16:15:42 +0100 Subject: [PATCH] Fixed missing path state resetting on stale path rediscovery --- RNS/Transport.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/RNS/Transport.py b/RNS/Transport.py index d2a88c4..ef46463 100755 --- a/RNS/Transport.py +++ b/RNS/Transport.py @@ -1349,6 +1349,7 @@ class Transport: # TODO: Check whether this approach works # under all circumstances if not random_blob in random_blobs: + Transport.mark_path_unknown_state(packet.destination_hash) should_add = True else: should_add = False @@ -1376,6 +1377,7 @@ class Transport: # TODO: Check that this ^ approach actually # works under all circumstances RNS.log("Replacing destination table entry for "+str(RNS.prettyhexrep(packet.destination_hash))+" with new announce due to expired path", RNS.LOG_DEBUG) + Transport.mark_path_unknown_state(packet.destination_hash) should_add = True else: should_add = False @@ -1386,6 +1388,7 @@ class Transport: if (announce_emitted > path_announce_emitted): if not random_blob in random_blobs: RNS.log("Replacing destination table entry for "+str(RNS.prettyhexrep(packet.destination_hash))+" with new announce, since it was more recently emitted", RNS.LOG_DEBUG) + Transport.mark_path_unknown_state(packet.destination_hash) should_add = True else: should_add = False @@ -2097,6 +2100,22 @@ class Transport: else: return False + @staticmethod + def mark_path_responsive(destination_hash): + if destination_hash in Transport.destination_table: + Transport.path_states[destination_hash] = Transport.STATE_RESPONSIVE + return True + else: + return False + + @staticmethod + def mark_path_unknown_state(destination_hash): + if destination_hash in Transport.destination_table: + Transport.path_states[destination_hash] = Transport.STATE_UNKNOWN + return True + else: + return False + def path_is_unresponsive(destination_hash): if destination_hash in Transport.path_states: if Transport.path_states[destination_hash] == Transport.STATE_UNRESPONSIVE: