Transmit proofs only on relevant interface

This commit is contained in:
Mark Qvist
2020-03-06 22:45:05 +01:00
parent d754ed989c
commit 3bbda5a4b4
4 changed files with 8 additions and 8 deletions
+1 -1
View File
@@ -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):
+3 -1
View File
@@ -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
+3 -5
View File
@@ -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)