mirror of
https://github.com/markqvist/Reticulum.git
synced 2026-11-19 14:36:34 -05:00
Refactored traffic accounting
This commit is contained in:
parent
d5f1e014db
commit
01e7ed8443
14 changed files with 14 additions and 35 deletions
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue