From 71c3333e10f0338ceeaf66cfeee2b83ecf90b5ff Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sun, 29 Aug 2021 12:28:30 +0200 Subject: [PATCH] Improved announce handling for local clients. --- RNS/Transport.py | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/RNS/Transport.py b/RNS/Transport.py index 91d6881..fbd7dcb 100755 --- a/RNS/Transport.py +++ b/RNS/Transport.py @@ -734,19 +734,20 @@ class Transport: announce_context = RNS.Packet.NONE announce_data = packet.data - new_announce = RNS.Packet( - announce_destination, - announce_data, - RNS.Packet.ANNOUNCE, - context = announce_context, - header_type = RNS.Packet.HEADER_2, - transport_type = Transport.TRANSPORT, - transport_id = Transport.identity.hash, - attached_interface = attached_interface - ) + for local_interface in Transport.local_client_interfaces: + new_announce = RNS.Packet( + announce_destination, + announce_data, + RNS.Packet.ANNOUNCE, + context = announce_context, + header_type = RNS.Packet.HEADER_2, + transport_type = Transport.TRANSPORT, + transport_id = Transport.identity.hash, + attached_interface = local_interface + ) - new_announce.hops = packet.hops - new_announce.send() + new_announce.hops = packet.hops + new_announce.send() Transport.destination_table[packet.destination_hash] = [now, received_from, announce_hops, expires, random_blobs, packet.receiving_interface, packet] RNS.log("Path to "+RNS.prettyhexrep(packet.destination_hash)+" is now "+str(announce_hops)+" hops away via "+RNS.prettyhexrep(received_from)+" on "+str(packet.receiving_interface), RNS.LOG_VERBOSE) @@ -866,7 +867,7 @@ class Transport: else: # TODO: This looks like it should actually # be rewritten when implicit proofs are added. - + # In case of an implicit proof, we have # to check every single outstanding receipt receipt_validated = receipt.validate_proof_packet(packet) @@ -883,8 +884,13 @@ class Transport: for registered_destination in Transport.destinations: if destination.hash == registered_destination.hash: raise KeyError("Attempt to register an already registered destination.") + Transport.destinations.append(destination) + if Transport.owner.is_connected_to_shared_instance: + if destination.type == RNS.Destination.SINGLE: + destination.announce(path_response=True) + @staticmethod def deregister_destination(destination): if destination in Transport.destinations: