From 488e617094d38b94369e0539082f06bff8004be3 Mon Sep 17 00:00:00 2001 From: "jacob.eva" Date: Sat, 8 Jun 2024 10:31:43 +0100 Subject: [PATCH] Fix duplicate interfaces on reconnect and beacon message spam bugs --- RNS/Interfaces/RNodeMultiInterface.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/RNS/Interfaces/RNodeMultiInterface.py b/RNS/Interfaces/RNodeMultiInterface.py index 8d440d7..a5d1a2f 100644 --- a/RNS/Interfaces/RNodeMultiInterface.py +++ b/RNS/Interfaces/RNodeMultiInterface.py @@ -815,11 +815,15 @@ class RNodeMultiInterface(Interface): if self.id_interval != None and self.id_callsign != None: if self.first_tx != None: if time.time() > self.first_tx + self.id_interval: - RNS.log("Interface "+str(self)+" is transmitting beacon data on all subinterfaces: "+str(self.id_callsign.decode("utf-8")), RNS.LOG_DEBUG) + interface_available = False for interface in self.subinterfaces: - if interface != 0: + if interface != 0 and interface.online: + interface_available = True self.subinterfaces[interface.index].processOutgoing(self.id_callsign) + if interface_available: + RNS.log("Interface "+str(self)+" is transmitting beacon data on all subinterfaces: "+str(self.id_callsign.decode("utf-8")), RNS.LOG_DEBUG) + sleep(0.08) except Exception as e: @@ -832,6 +836,8 @@ class RNodeMultiInterface(Interface): RNS.log("Reticulum will attempt to reconnect the interface periodically.", RNS.LOG_ERROR) + self.teardown_subinterfaces() + self.online = False try: self.serial.close() @@ -866,6 +872,14 @@ class RNodeMultiInterface(Interface): self.setRadioState(KISS.RADIO_STATE_OFF, interface) self.leave() + def teardown_subinterfaces(self): + for interface in self.subinterfaces: + if interface != 0: + if interface in RNS.Transport.interfaces: + RNS.Transport.interfaces.remove(interface) + self.subinterfaces[interface.index] = 0 + del interface + def should_ingress_limit(self): return False