From bc39a1acf1b0b69b9dbd129e8c51df4a2e970988 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Fri, 1 Jul 2022 21:16:01 +0200 Subject: [PATCH] Fixed static size index --- RNS/Interfaces/LocalInterface.py | 8 ++++---- RNS/Packet.py | 2 +- RNS/Transport.py | 14 ++++---------- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/RNS/Interfaces/LocalInterface.py b/RNS/Interfaces/LocalInterface.py index 276eff0..e0425d3 100644 --- a/RNS/Interfaces/LocalInterface.py +++ b/RNS/Interfaces/LocalInterface.py @@ -51,7 +51,7 @@ class LocalClientInterface(Interface): self.txb = 0 # TODO: Remove at some point - self.rxptime = 0 + # self.rxptime = 0 self.HW_MTU = 1064 @@ -142,13 +142,13 @@ class LocalClientInterface(Interface): self.parent_interface.rxb += len(data) # TODO: Remove at some point - processing_start = time.time() + # processing_start = time.time() self.owner.inbound(data, self) # TODO: Remove at some point - duration = time.time() - processing_start - self.rxptime += duration + # duration = time.time() - processing_start + # self.rxptime += duration def processOutgoing(self, data): if self.online: diff --git a/RNS/Packet.py b/RNS/Packet.py index 46ad940..8742ba8 100755 --- a/RNS/Packet.py +++ b/RNS/Packet.py @@ -315,7 +315,7 @@ class Packet: def get_hashable_part(self): hashable_part = bytes([self.raw[0] & 0b00001111]) if self.header_type == Packet.HEADER_2: - hashable_part += self.raw[12:] + hashable_part += self.raw[(RNS.Identity.TRUNCATED_HASHLENGTH//8)+2:] else: hashable_part += self.raw[2:] diff --git a/RNS/Transport.py b/RNS/Transport.py index 8f24f0e..4a4e298 100755 --- a/RNS/Transport.py +++ b/RNS/Transport.py @@ -658,10 +658,6 @@ class Transport: tx_time = (len(packet.raw)*8) / interface.bitrate wait_time = (tx_time / interface.announce_cap) interface.announce_allowed_at = outbound_time + wait_time - - # TODO: Clean - # wait_time_str = str(round(wait_time*1000,3))+"ms" - # RNS.log("Next announce on "+str(interface)+" allowed in "+wait_time_str, RNS.LOG_EXTREME) else: should_transmit = False @@ -955,13 +951,13 @@ class Transport: new_raw = packet.raw[0:1] new_raw += struct.pack("!B", packet.hops) new_raw += next_hop - new_raw += packet.raw[12:] + new_raw += packet.raw[(RNS.Identity.TRUNCATED_HASHLENGTH//8)+2:] elif remaining_hops == 1: # Strip transport headers and transmit new_flags = (RNS.Packet.HEADER_1) << 6 | (Transport.BROADCAST) << 4 | (packet.flags & 0b00001111) new_raw = struct.pack("!B", new_flags) new_raw += struct.pack("!B", packet.hops) - new_raw += packet.raw[12:] + new_raw += packet.raw[(RNS.Identity.TRUNCATED_HASHLENGTH//8)+2:] elif remaining_hops == 0: # Just increase hop count and transmit new_raw = packet.raw[0:1] @@ -1848,12 +1844,10 @@ class Transport: ) else: - # TODO: Reset this to debug level - RNS.log("Ignoring duplicate path request for "+RNS.prettyhexrep(destination_hash)+" with tag "+RNS.prettyhexrep(unique_tag), RNS.LOG_WARNING) + RNS.log("Ignoring duplicate path request for "+RNS.prettyhexrep(destination_hash)+" with tag "+RNS.prettyhexrep(unique_tag), RNS.LOG_DEBUG) else: - # TODO: Reset this to debug level - RNS.log("Ignoring tagless path request for "+RNS.prettyhexrep(destination_hash), RNS.LOG_WARNING) + RNS.log("Ignoring tagless path request for "+RNS.prettyhexrep(destination_hash), RNS.LOG_DEBUG) except Exception as e: RNS.log("Error while handling path request. The contained exception was: "+str(e), RNS.LOG_ERROR)