Link activation time

This commit is contained in:
Mark Qvist 2021-12-11 17:26:45 +01:00
parent c96e067839
commit 20dfbcf0cc
2 changed files with 12 additions and 0 deletions

View File

@ -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)

View File

@ -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: