diff --git a/RNS/Interfaces/AX25KISSInterface.py b/RNS/Interfaces/AX25KISSInterface.py index 562de5d4..ae7f0e36 100644 --- a/RNS/Interfaces/AX25KISSInterface.py +++ b/RNS/Interfaces/AX25KISSInterface.py @@ -266,9 +266,7 @@ class AX25KISSInterface(Interface): def process_incoming(self, data): - if (len(data) > AX25.HEADER_SIZE): - self.rxb += len(data) - self.owner.inbound(data[AX25.HEADER_SIZE:], self) + if (len(data) > AX25.HEADER_SIZE): self.owner.inbound(data[AX25.HEADER_SIZE:], self) def process_outgoing(self,data): diff --git a/RNS/Interfaces/AutoInterface.py b/RNS/Interfaces/AutoInterface.py index c32ef6c4..5514449d 100644 --- a/RNS/Interfaces/AutoInterface.py +++ b/RNS/Interfaces/AutoInterface.py @@ -663,8 +663,6 @@ class AutoInterfacePeer(Interface): self.owner.refresh_peer(self.addr) self.owner.mif_deque.append(data_hash) self.owner.mif_deque_times.append([data_hash, time.time()]) - self.rxb += len(data) - self.owner.rxb += len(data) self.owner.owner.inbound(data, self) def process_outgoing(self, data): diff --git a/RNS/Interfaces/BackboneInterface.py b/RNS/Interfaces/BackboneInterface.py index 2976dc82..47a30ac3 100644 --- a/RNS/Interfaces/BackboneInterface.py +++ b/RNS/Interfaces/BackboneInterface.py @@ -1043,10 +1043,6 @@ class BackboneClientInterface(Interface): def process_incoming(self, data): if self.online and not self.detached: - self.rxb += len(data) - if hasattr(self, "parent_interface") and self.parent_interface != None: - self.parent_interface.rxb += len(data) - self.dp_ingress_packets += 1 self.owner.inbound(data, self) diff --git a/RNS/Interfaces/I2PInterface.py b/RNS/Interfaces/I2PInterface.py index f231df8c..892420e4 100644 --- a/RNS/Interfaces/I2PInterface.py +++ b/RNS/Interfaces/I2PInterface.py @@ -538,9 +538,6 @@ class I2PInterfacePeer(Interface): def process_incoming(self, data): if not data: return - self.rxb += len(data) - if hasattr(self, "parent_interface") and self.parent_interface != None and self.parent_count: - self.parent_interface.rxb += len(data) self.owner.inbound(data, self) def process_outgoing(self, data): diff --git a/RNS/Interfaces/KISSInterface.py b/RNS/Interfaces/KISSInterface.py index 9323ea6f..419ab2e2 100644 --- a/RNS/Interfaces/KISSInterface.py +++ b/RNS/Interfaces/KISSInterface.py @@ -255,7 +255,6 @@ class KISSInterface(Interface): def process_incoming(self, data): if not data: return - self.rxb += len(data) self.owner.inbound(data, self) diff --git a/RNS/Interfaces/LocalInterface.py b/RNS/Interfaces/LocalInterface.py index bef1c3a2..391a99c5 100644 --- a/RNS/Interfaces/LocalInterface.py +++ b/RNS/Interfaces/LocalInterface.py @@ -202,9 +202,6 @@ class LocalClientInterface(Interface): except Exception as e: RNS.log(f"Exception occurred while sending keepalive on {self}: {e}", RNS.LOG_ERROR) def process_incoming(self, data): - self.rxb += len(data) - if self.parent_interface != None: self.parent_interface.rxb += len(data) - try: self.owner.inbound(data, self) except Exception as e: RNS.log(f"An error occurred in the processing of an incoming frame for {self}: {e}", RNS.LOG_ERROR) diff --git a/RNS/Interfaces/PipeInterface.py b/RNS/Interfaces/PipeInterface.py index eca88b5c..e708c966 100644 --- a/RNS/Interfaces/PipeInterface.py +++ b/RNS/Interfaces/PipeInterface.py @@ -121,7 +121,6 @@ class PipeInterface(Interface): def process_incoming(self, data): if not data: return - self.rxb += len(data) self.owner.inbound(data, self) diff --git a/RNS/Interfaces/RNodeInterface.py b/RNS/Interfaces/RNodeInterface.py index b890b09d..87cc1a6d 100644 --- a/RNS/Interfaces/RNodeInterface.py +++ b/RNS/Interfaces/RNodeInterface.py @@ -706,7 +706,6 @@ class RNodeInterface(Interface): def process_incoming(self, data): if not data: return - self.rxb += len(data) self.owner.inbound(data, self) def process_outgoing(self,data): diff --git a/RNS/Interfaces/RNodeMultiInterface.py b/RNS/Interfaces/RNodeMultiInterface.py index b3e6dc54..45eb0fd1 100644 --- a/RNS/Interfaces/RNodeMultiInterface.py +++ b/RNS/Interfaces/RNodeMultiInterface.py @@ -1130,7 +1130,6 @@ class RNodeSubInterface(Interface): def process_incoming(self, data): if not data: return - self.rxb += len(data) self.owner.inbound(data, self) def process_outgoing(self,data): diff --git a/RNS/Interfaces/SerialInterface.py b/RNS/Interfaces/SerialInterface.py index 0e8d7665..671994a6 100755 --- a/RNS/Interfaces/SerialInterface.py +++ b/RNS/Interfaces/SerialInterface.py @@ -151,7 +151,6 @@ class SerialInterface(Interface): def process_incoming(self, data): if not data: return - self.rxb += len(data) self.owner.inbound(data, self) def process_outgoing(self,data): diff --git a/RNS/Interfaces/TCPInterface.py b/RNS/Interfaces/TCPInterface.py index d4cfae87..2ffbd4bc 100644 --- a/RNS/Interfaces/TCPInterface.py +++ b/RNS/Interfaces/TCPInterface.py @@ -305,10 +305,6 @@ class TCPClientInterface(Interface): def process_incoming(self, data): if not data: return if self.online and not self.detached: - self.rxb += len(data) - if hasattr(self, "parent_interface") and self.parent_interface != None: - self.parent_interface.rxb += len(data) - self.owner.inbound(data, self) def process_outgoing(self, data): diff --git a/RNS/Interfaces/UDPInterface.py b/RNS/Interfaces/UDPInterface.py index e2baecac..e24c5dd8 100644 --- a/RNS/Interfaces/UDPInterface.py +++ b/RNS/Interfaces/UDPInterface.py @@ -124,7 +124,6 @@ class UDPInterface(Interface): def process_incoming(self, data): if not data: return - self.rxb += len(data) self.owner.inbound(data, self) def process_outgoing(self,data): diff --git a/RNS/Interfaces/WeaveInterface.py b/RNS/Interfaces/WeaveInterface.py index f6bf3e74..2aa987e0 100644 --- a/RNS/Interfaces/WeaveInterface.py +++ b/RNS/Interfaces/WeaveInterface.py @@ -249,7 +249,6 @@ class WDCL(): self.online = True def process_incoming(self, data): - self.rxb += len(data) if self.device: while len(self.frame_queue): self.device.incoming_frame(self.frame_queue.pop()) self.device.incoming_frame(data) @@ -1060,8 +1059,6 @@ class WeaveInterfacePeer(Interface): self.owner.refresh_peer(self.endpoint_addr) self.owner.mif_deque.append(data_hash) self.owner.mif_deque_times.append([data_hash, time.time()]) - self.rxb += len(data) - self.owner.rxb += len(data) self.owner.owner.inbound(data, self) def process_outgoing(self, data): diff --git a/RNS/Transport.py b/RNS/Transport.py index 1ed773d5..48547246 100755 --- a/RNS/Transport.py +++ b/RNS/Transport.py @@ -1944,16 +1944,22 @@ class Transport: def filtered_inbound(raw=None, interface=None): if interface: raw_len = len(raw) if raw else 0 - interface.rxb -= raw_len; interface.frxb += raw_len - if interface.parent_interface: - interface.parent_interface.rxb -= raw_len - interface.parent_interface.frxb += raw_len + interface.frxb += raw_len + if interface.parent_interface: interface.parent_interface.frxb += raw_len + + @staticmethod + def accepted_inbound(raw=None, interface=None): + if interface: + raw_len = len(raw) if raw else 0 + interface.rxb += raw_len + if interface.parent_interface: interface.parent_interface.rxb += raw_len @staticmethod def inbound(raw, interface=None, tc=None, ifac_handled=False): try: - if not Transport.preprocess_inbound(raw=raw, interface=interface, tc=tc, ifac_handled=ifac_handled): - Transport.filtered_inbound(raw=raw, interface=interface) + accepted = Transport.preprocess_inbound(raw=raw, interface=interface, tc=tc, ifac_handled=ifac_handled) + if accepted: Transport.accepted_inbound(raw=raw, interface=interface) + else: Transport.filtered_inbound(raw=raw, interface=interface) except Exception as e: RNS.log(f"Error while processing inbound on {interface}: {e}", RNS.LOG_ERROR) RNS.trace_exception(e) @@ -2214,7 +2220,7 @@ class Transport: # but this will need to be kept *tightly* in-sync. Transport.rx_packets += 1 - if not Transport.USE_INBOUND_QUEUE: return Transport._inbound(packet) + if not Transport.USE_INBOUND_QUEUE: Transport._inbound(packet) else: if traffic_class == Transport.TC_INGRESS_LIMITED: packet.traffic_class = Transport.TC_INGRESS_LIMITED try: Transport.inbound_queues.put(traffic_class, packet, block=False)