From 3bbda5a4b489a27ae002669a2987c85e67639f26 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Fri, 6 Mar 2020 22:45:05 +0100 Subject: [PATCH] Transmit proofs only on relevant interface --- README.md | 2 +- RNS/Identity.py | 2 +- RNS/Packet.py | 4 +++- RNS/Transport.py | 8 +++----- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index ac6697a..da005e4 100755 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Reticulum can also be tunneled over existing IP networks. Some countries still ban the use of encryption when operating under an amateur radio license. Reticulum offers several encryptionless modes, while still using cryptographic principles for station verification, link establishment, data integrity verification, acknowledgements and routing. It is therefore perfectly possible to include Reticulum in amateur radio use, even if your country bans encryption. ## How do I get started? -Full documentation and video tutorials are coming with the stable alpha release. Until then, you are on your own. If you really want to experiment already, you could take a look in the "Examples" folder, for some well-documented example programs. Be sure to also read the [Reticulum Overview Document](http://unsigned.io/wp-content/uploads/2018/04/Reticulum_Overview_v0.4.pdf) +Full documentation and video tutorials are coming with the stable alpha release. Until then, you are mostly on your own. If you really want to experiment already, you could take a look in the "Examples" folder, for some well-documented example programs. Be sure to also read the [Reticulum Overview Document](http://unsigned.io/wp-content/uploads/2018/04/Reticulum_Overview_v0.4.pdf) ## Dependencies: - cryptography.io diff --git a/RNS/Identity.py b/RNS/Identity.py index 09de315..9f1ef4e 100644 --- a/RNS/Identity.py +++ b/RNS/Identity.py @@ -317,7 +317,7 @@ class Identity: if destination == None: destination = packet.generateProofDestination() - proof = RNS.Packet(destination, proof_data, RNS.Packet.PROOF) + proof = RNS.Packet(destination, proof_data, RNS.Packet.PROOF, attached_interface = packet.receiving_interface) proof.send() def __str__(self): diff --git a/RNS/Packet.py b/RNS/Packet.py index b0b9a27..b61d32e 100755 --- a/RNS/Packet.py +++ b/RNS/Packet.py @@ -48,7 +48,7 @@ class Packet: # Default packet timeout TIMEOUT = 60 - def __init__(self, destination, data, packet_type = DATA, context = NONE, transport_type = RNS.Transport.BROADCAST, header_type = HEADER_1, transport_id = None): + def __init__(self, destination, data, packet_type = DATA, context = NONE, transport_type = RNS.Transport.BROADCAST, header_type = HEADER_1, transport_id = None, attached_interface = None): if destination != None: if transport_type == None: transport_type = RNS.Transport.BROADCAST @@ -78,6 +78,8 @@ class Packet: self.sent_at = None self.packet_hash = None + self.attached_interface = attached_interface + def getPackedFlags(self): if self.context == Packet.LRPROOF: packed_flags = (self.header_type << 6) | (self.transport_type << 4) | RNS.Destination.LINK | self.packet_type diff --git a/RNS/Transport.py b/RNS/Transport.py index 32b07b5..34d291b 100755 --- a/RNS/Transport.py +++ b/RNS/Transport.py @@ -189,8 +189,6 @@ class Transport: new_raw += packet.raw[1:2] new_raw += Transport.destination_table[packet.destination_hash][1] new_raw += packet.raw[2:] - # RNS.log("Transporting "+str(len(packet.raw))+" bytes via "+RNS.prettyhexrep(Transport.destination_table[packet.destination_hash][1])+" on: "+str(outbound_interface), RNS.LOG_EXTREME) - # RNS.log("Hash is "+RNS.prettyhexrep(packet.packet_hash), RNS.LOG_EXTREME) RNS.log("Packet was inserted into transport via "+RNS.prettyhexrep(Transport.destination_table[packet.destination_hash][1])+" on: "+str(outbound_interface), RNS.LOG_DEBUG) outbound_interface.processOutgoing(new_raw) sent = True @@ -205,7 +203,7 @@ class Transport: else: # Broadcast packet on all outgoing interfaces, or relevant - # interface, if packet is for a link + # interface, if packet is for a link or has an attachede interface for interface in Transport.interfaces: if interface.OUT: should_transmit = True @@ -214,8 +212,8 @@ class Transport: should_transmit = False if interface != packet.destination.attached_interface: should_transmit = False - else: - pass + if packet.attached_interface != None and interface != packet.attached_interface: + should_transmit = False if should_transmit: RNS.log("Transmitting "+str(len(packet.raw))+" bytes on: "+str(interface), RNS.LOG_EXTREME)