Refactored processIncoming to process_incoming

This commit is contained in:
Mark Qvist 2024-11-22 14:39:27 +01:00
parent 434ebd2954
commit 823bfd537c
14 changed files with 31 additions and 31 deletions

View File

@ -245,7 +245,7 @@ class AX25KISSInterface(Interface):
raise IOError("Could not enable AX.25 KISS interface flow control") raise IOError("Could not enable AX.25 KISS interface flow control")
def processIncoming(self, data): def process_incoming(self, data):
if (len(data) > AX25.HEADER_SIZE): if (len(data) > AX25.HEADER_SIZE):
self.rxb += len(data) self.rxb += len(data)
self.owner.inbound(data[AX25.HEADER_SIZE:], self) self.owner.inbound(data[AX25.HEADER_SIZE:], self)
@ -320,7 +320,7 @@ class AX25KISSInterface(Interface):
if (in_frame and byte == KISS.FEND and command == KISS.CMD_DATA): if (in_frame and byte == KISS.FEND and command == KISS.CMD_DATA):
in_frame = False in_frame = False
self.processIncoming(data_buffer) self.process_incoming(data_buffer)
elif (byte == KISS.FEND): elif (byte == KISS.FEND):
in_frame = True in_frame = True
command = KISS.CMD_UNKNOWN command = KISS.CMD_UNKNOWN

View File

@ -283,7 +283,7 @@ class KISSInterface(Interface):
raise IOError("Could not enable KISS interface flow control") raise IOError("Could not enable KISS interface flow control")
def processIncoming(self, data): def process_incoming(self, data):
self.rxb += len(data) self.rxb += len(data)
def af(): def af():
self.owner.inbound(data, self) self.owner.inbound(data, self)
@ -344,7 +344,7 @@ class KISSInterface(Interface):
if (in_frame and byte == KISS.FEND and command == KISS.CMD_DATA): if (in_frame and byte == KISS.FEND and command == KISS.CMD_DATA):
in_frame = False in_frame = False
self.processIncoming(data_buffer) self.process_incoming(data_buffer)
elif (byte == KISS.FEND): elif (byte == KISS.FEND):
in_frame = True in_frame = True
command = KISS.CMD_UNKNOWN command = KISS.CMD_UNKNOWN

View File

@ -957,7 +957,7 @@ class RNodeInterface(Interface):
except: except:
self.bitrate = 0 self.bitrate = 0
def processIncoming(self, data): def process_incoming(self, data):
self.rxb += len(data) self.rxb += len(data)
def af(): def af():
@ -1023,7 +1023,7 @@ class RNodeInterface(Interface):
if (in_frame and byte == KISS.FEND and command == KISS.CMD_DATA): if (in_frame and byte == KISS.FEND and command == KISS.CMD_DATA):
in_frame = False in_frame = False
self.processIncoming(data_buffer) self.process_incoming(data_buffer)
data_buffer = b"" data_buffer = b""
command_buffer = b"" command_buffer = b""
elif (byte == KISS.FEND): elif (byte == KISS.FEND):

View File

@ -184,7 +184,7 @@ class SerialInterface(Interface):
RNS.log("Serial port "+self.port+" is now open", RNS.LOG_VERBOSE) RNS.log("Serial port "+self.port+" is now open", RNS.LOG_VERBOSE)
def processIncoming(self, data): def process_incoming(self, data):
self.rxb += len(data) self.rxb += len(data)
def af(): def af():
self.owner.inbound(data, self) self.owner.inbound(data, self)
@ -214,7 +214,7 @@ class SerialInterface(Interface):
if (in_frame and byte == HDLC.FLAG): if (in_frame and byte == HDLC.FLAG):
in_frame = False in_frame = False
self.processIncoming(data_buffer) self.process_incoming(data_buffer)
elif (byte == HDLC.FLAG): elif (byte == HDLC.FLAG):
in_frame = True in_frame = True
data_buffer = b"" data_buffer = b""

View File

@ -299,7 +299,7 @@ class AutoInterface(Interface):
addr_info = socket.getaddrinfo(local_addr, self.data_port, socket.AF_INET6, socket.SOCK_DGRAM) addr_info = socket.getaddrinfo(local_addr, self.data_port, socket.AF_INET6, socket.SOCK_DGRAM)
address = addr_info[0][4] address = addr_info[0][4]
udp_server = socketserver.UDPServer(address, self.handler_factory(self.processIncoming)) udp_server = socketserver.UDPServer(address, self.handler_factory(self.process_incoming))
self.interface_servers[ifname] = udp_server self.interface_servers[ifname] = udp_server
thread = threading.Thread(target=udp_server.serve_forever) thread = threading.Thread(target=udp_server.serve_forever)
@ -381,7 +381,7 @@ class AutoInterface(Interface):
RNS.log("Starting new UDP listener for "+str(self)+" "+str(ifname), RNS.LOG_DEBUG) RNS.log("Starting new UDP listener for "+str(self)+" "+str(ifname), RNS.LOG_DEBUG)
udp_server = socketserver.UDPServer(listen_address, self.handler_factory(self.processIncoming)) udp_server = socketserver.UDPServer(listen_address, self.handler_factory(self.process_incoming))
self.interface_servers[ifname] = udp_server self.interface_servers[ifname] = udp_server
thread = threading.Thread(target=udp_server.serve_forever) thread = threading.Thread(target=udp_server.serve_forever)
@ -455,7 +455,7 @@ class AutoInterface(Interface):
def refresh_peer(self, addr): def refresh_peer(self, addr):
self.peers[addr][1] = time.time() self.peers[addr][1] = time.time()
def processIncoming(self, data): def process_incoming(self, data):
data_hash = RNS.Identity.full_hash(data) data_hash = RNS.Identity.full_hash(data)
deque_hit = False deque_hit = False
if data_hash in self.mif_deque: if data_hash in self.mif_deque:

View File

@ -627,7 +627,7 @@ class I2PInterfacePeer(Interface):
RNS.log("Attempt to reconnect on a non-initiator I2P interface. This should not happen.", RNS.LOG_ERROR) RNS.log("Attempt to reconnect on a non-initiator I2P interface. This should not happen.", RNS.LOG_ERROR)
raise IOError("Attempt to reconnect on a non-initiator I2P interface") raise IOError("Attempt to reconnect on a non-initiator I2P interface")
def processIncoming(self, data): def process_incoming(self, data):
self.rxb += len(data) self.rxb += len(data)
if hasattr(self, "parent_interface") and self.parent_interface != None and self.parent_count: if hasattr(self, "parent_interface") and self.parent_interface != None and self.parent_count:
self.parent_interface.rxb += len(data) self.parent_interface.rxb += len(data)
@ -732,7 +732,7 @@ class I2PInterfacePeer(Interface):
# Read loop for KISS framing # Read loop for KISS framing
if (in_frame and byte == KISS.FEND and command == KISS.CMD_DATA): if (in_frame and byte == KISS.FEND and command == KISS.CMD_DATA):
in_frame = False in_frame = False
self.processIncoming(data_buffer) self.process_incoming(data_buffer)
elif (byte == KISS.FEND): elif (byte == KISS.FEND):
in_frame = True in_frame = True
command = KISS.CMD_UNKNOWN command = KISS.CMD_UNKNOWN
@ -759,7 +759,7 @@ class I2PInterfacePeer(Interface):
# Read loop for HDLC framing # Read loop for HDLC framing
if (in_frame and byte == HDLC.FLAG): if (in_frame and byte == HDLC.FLAG):
in_frame = False in_frame = False
self.processIncoming(data_buffer) self.process_incoming(data_buffer)
elif (byte == HDLC.FLAG): elif (byte == HDLC.FLAG):
in_frame = True in_frame = True
data_buffer = b"" data_buffer = b""

View File

@ -236,7 +236,7 @@ class KISSInterface(Interface):
raise IOError("Could not enable KISS interface flow control") raise IOError("Could not enable KISS interface flow control")
def processIncoming(self, data): def process_incoming(self, data):
self.rxb += len(data) self.rxb += len(data)
self.owner.inbound(data, self) self.owner.inbound(data, self)
@ -294,7 +294,7 @@ class KISSInterface(Interface):
if (in_frame and byte == KISS.FEND and command == KISS.CMD_DATA): if (in_frame and byte == KISS.FEND and command == KISS.CMD_DATA):
in_frame = False in_frame = False
self.processIncoming(data_buffer) self.process_incoming(data_buffer)
elif (byte == KISS.FEND): elif (byte == KISS.FEND):
in_frame = True in_frame = True
command = KISS.CMD_UNKNOWN command = KISS.CMD_UNKNOWN

View File

@ -152,7 +152,7 @@ class LocalClientInterface(Interface):
raise IOError("Attempt to reconnect on a non-initiator local interface") raise IOError("Attempt to reconnect on a non-initiator local interface")
def processIncoming(self, data): def process_incoming(self, data):
self.rxb += len(data) self.rxb += len(data)
if hasattr(self, "parent_interface") and self.parent_interface != None: if hasattr(self, "parent_interface") and self.parent_interface != None:
self.parent_interface.rxb += len(data) self.parent_interface.rxb += len(data)
@ -208,7 +208,7 @@ class LocalClientInterface(Interface):
pointer += 1 pointer += 1
if (in_frame and byte == HDLC.FLAG): if (in_frame and byte == HDLC.FLAG):
in_frame = False in_frame = False
self.processIncoming(data_buffer) self.process_incoming(data_buffer)
elif (byte == HDLC.FLAG): elif (byte == HDLC.FLAG):
in_frame = True in_frame = True
data_buffer = b"" data_buffer = b""

View File

@ -110,7 +110,7 @@ class PipeInterface(Interface):
RNS.log("Subprocess pipe for "+str(self)+" is now connected", RNS.LOG_VERBOSE) RNS.log("Subprocess pipe for "+str(self)+" is now connected", RNS.LOG_VERBOSE)
def processIncoming(self, data): def process_incoming(self, data):
self.rxb += len(data) self.rxb += len(data)
self.owner.inbound(data, self) self.owner.inbound(data, self)
@ -143,7 +143,7 @@ class PipeInterface(Interface):
if (in_frame and byte == HDLC.FLAG): if (in_frame and byte == HDLC.FLAG):
in_frame = False in_frame = False
self.processIncoming(data_buffer) self.process_incoming(data_buffer)
elif (byte == HDLC.FLAG): elif (byte == HDLC.FLAG):
in_frame = True in_frame = True
data_buffer = b"" data_buffer = b""

View File

@ -597,7 +597,7 @@ class RNodeInterface(Interface):
except: except:
self.bitrate = 0 self.bitrate = 0
def processIncoming(self, data): def process_incoming(self, data):
self.rxb += len(data) self.rxb += len(data)
self.owner.inbound(data, self) self.owner.inbound(data, self)
self.r_stat_rssi = None self.r_stat_rssi = None
@ -655,7 +655,7 @@ class RNodeInterface(Interface):
if (in_frame and byte == KISS.FEND and command == KISS.CMD_DATA): if (in_frame and byte == KISS.FEND and command == KISS.CMD_DATA):
in_frame = False in_frame = False
self.processIncoming(data_buffer) self.process_incoming(data_buffer)
data_buffer = b"" data_buffer = b""
command_buffer = b"" command_buffer = b""
elif (byte == KISS.FEND): elif (byte == KISS.FEND):

View File

@ -614,7 +614,7 @@ class RNodeMultiInterface(Interface):
command == KISS.CMD_INT10_DATA or command == KISS.CMD_INT10_DATA or
command == KISS.CMD_INT11_DATA)): command == KISS.CMD_INT11_DATA)):
in_frame = False in_frame = False
self.subinterfaces[KISS.int_data_cmd_to_index(command)].processIncoming(data_buffer) self.subinterfaces[KISS.int_data_cmd_to_index(command)].process_incoming(data_buffer)
self.selected_index = KISS.int_data_cmd_to_index(command) self.selected_index = KISS.int_data_cmd_to_index(command)
data_buffer = b"" data_buffer = b""
command_buffer = b"" command_buffer = b""
@ -1199,7 +1199,7 @@ class RNodeSubInterface(Interface):
except: except:
self.bitrate = 0 self.bitrate = 0
def processIncoming(self, data): def process_incoming(self, data):
self.rxb += len(data) self.rxb += len(data)
self.owner.inbound(data, self) self.owner.inbound(data, self)
self.r_stat_rssi = None self.r_stat_rssi = None

View File

@ -133,7 +133,7 @@ class SerialInterface(Interface):
RNS.log("Serial port "+self.port+" is now open", RNS.LOG_VERBOSE) RNS.log("Serial port "+self.port+" is now open", RNS.LOG_VERBOSE)
def processIncoming(self, data): def process_incoming(self, data):
self.rxb += len(data) self.rxb += len(data)
self.owner.inbound(data, self) self.owner.inbound(data, self)
@ -161,7 +161,7 @@ class SerialInterface(Interface):
if (in_frame and byte == HDLC.FLAG): if (in_frame and byte == HDLC.FLAG):
in_frame = False in_frame = False
self.processIncoming(data_buffer) self.process_incoming(data_buffer)
elif (byte == HDLC.FLAG): elif (byte == HDLC.FLAG):
in_frame = True in_frame = True
data_buffer = b"" data_buffer = b""

View File

@ -284,7 +284,7 @@ class TCPClientInterface(Interface):
RNS.log("Attempt to reconnect on a non-initiator TCP interface. This should not happen.", RNS.LOG_ERROR) RNS.log("Attempt to reconnect on a non-initiator TCP interface. This should not happen.", RNS.LOG_ERROR)
raise IOError("Attempt to reconnect on a non-initiator TCP interface") raise IOError("Attempt to reconnect on a non-initiator TCP interface")
def processIncoming(self, data): def process_incoming(self, data):
self.rxb += len(data) self.rxb += len(data)
if hasattr(self, "parent_interface") and self.parent_interface != None: if hasattr(self, "parent_interface") and self.parent_interface != None:
self.parent_interface.rxb += len(data) self.parent_interface.rxb += len(data)
@ -335,7 +335,7 @@ class TCPClientInterface(Interface):
# Read loop for KISS framing # Read loop for KISS framing
if (in_frame and byte == KISS.FEND and command == KISS.CMD_DATA): if (in_frame and byte == KISS.FEND and command == KISS.CMD_DATA):
in_frame = False in_frame = False
self.processIncoming(data_buffer) self.process_incoming(data_buffer)
elif (byte == KISS.FEND): elif (byte == KISS.FEND):
in_frame = True in_frame = True
command = KISS.CMD_UNKNOWN command = KISS.CMD_UNKNOWN
@ -362,7 +362,7 @@ class TCPClientInterface(Interface):
# Read loop for HDLC framing # Read loop for HDLC framing
if (in_frame and byte == HDLC.FLAG): if (in_frame and byte == HDLC.FLAG):
in_frame = False in_frame = False
self.processIncoming(data_buffer) self.process_incoming(data_buffer)
elif (byte == HDLC.FLAG): elif (byte == HDLC.FLAG):
in_frame = True in_frame = True
data_buffer = b"" data_buffer = b""

View File

@ -91,7 +91,7 @@ class UDPInterface(Interface):
self.owner = owner self.owner = owner
address = (self.bind_ip, self.bind_port) address = (self.bind_ip, self.bind_port)
socketserver.UDPServer.address_family = socket.AF_INET socketserver.UDPServer.address_family = socket.AF_INET
self.server = socketserver.UDPServer(address, handlerFactory(self.processIncoming)) self.server = socketserver.UDPServer(address, handlerFactory(self.process_incoming))
thread = threading.Thread(target=self.server.serve_forever) thread = threading.Thread(target=self.server.serve_forever)
thread.daemon = True thread.daemon = True
@ -105,7 +105,7 @@ class UDPInterface(Interface):
self.forward_port = forwardport self.forward_port = forwardport
def processIncoming(self, data): def process_incoming(self, data):
self.rxb += len(data) self.rxb += len(data)
self.owner.inbound(data, self) self.owner.inbound(data, self)