From 20dfbcf0cc86a0b9f4f08ecf4177ee3343a76c3b Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sat, 11 Dec 2021 17:26:45 +0100 Subject: [PATCH] Link activation time --- RNS/Link.py | 4 ++++ RNS/Transport.py | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/RNS/Link.py b/RNS/Link.py index 0748dc7..4166458 100644 --- a/RNS/Link.py +++ b/RNS/Link.py @@ -123,6 +123,7 @@ class Link: self.keepalive = Link.KEEPALIVE self.watchdog_lock = False self.status = Link.PENDING + self.activated_at = None self.type = RNS.Destination.LINK self.owner = owner self.destination = destination @@ -245,6 +246,7 @@ class Link: self.had_outbound() self.status = Link.ACTIVE + self.activated_at = time.time() if self.callbacks.link_established != None: thread = threading.Thread(target=self.callbacks.link_established, args=(self,)) thread.setDaemon(True) @@ -334,6 +336,8 @@ class Link: rtt = umsgpack.unpackb(plaintext) self.rtt = max(measured_rtt, rtt) self.status = Link.ACTIVE + self.activated_at = time.time() + if self.owner.callbacks.link_established != None: self.owner.callbacks.link_established(self) diff --git a/RNS/Transport.py b/RNS/Transport.py index 0d397fb..e21074d 100755 --- a/RNS/Transport.py +++ b/RNS/Transport.py @@ -1032,6 +1032,9 @@ class Transport: # Handling for proofs and link-request proofs elif packet.packet_type == RNS.Packet.PROOF: if packet.context == RNS.Packet.LRPROOF: + # TODO: Remove debug + RNS.log("Link request proof received") + # This is a link request proof, check if it # needs to be transported if (RNS.Reticulum.transport_enabled() or for_local_client_link or from_local_client) and packet.destination_hash in Transport.link_table: @@ -1048,10 +1051,15 @@ class Transport: else: RNS.log("Link request proof received on wrong interface, not transporting it.", RNS.LOG_DEBUG) else: + # TODO: Remove debug + RNS.log("Could not transport link request proof") + # Check if we can deliver it to a local # pending link for link in Transport.pending_links: if link.link_id == packet.destination_hash: + # TODO: Remove debug + RNS.log("Delivering link request proof to local pending link", RNS.LOG_DEBUG) link.validate_proof(packet) elif packet.context == RNS.Packet.RESOURCE_PRF: