From 26aec0040e822872531b857dfaf9ae932526039b Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Tue, 29 Sep 2026 14:52:49 +0200 Subject: [PATCH] Use canonical interface detach in auto-connected interface monitor job --- RNS/Discovery.py | 6 +++--- RNS/Reticulum.py | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/RNS/Discovery.py b/RNS/Discovery.py index 4f629111..ebd6acac 100644 --- a/RNS/Discovery.py +++ b/RNS/Discovery.py @@ -710,9 +710,9 @@ class InterfaceDiscovery(): RNS.log(f"Error while de-registering auto-connected interface from transport: {e}", RNS.LOG_ERROR) def teardown_interface(self, interface): - interface.detach() - RNS.Transport.remove_interface(interface) - if interface in self.monitored_interfaces: self.monitored_interfaces.remove(interface) + was_detached = RNS.Reticulum.get_instance()._detach_interface(interface.name, internal_forced=True) + if was_detached and interface in self.monitored_interfaces: self.monitored_interfaces.remove(interface) + if not was_detached: RNS.log(f"Could not detach auto-connected interface {interface}", RNS.LOG_ERROR) def autoconnect_count(self): return len([i for i in RNS.Transport.interfaces if hasattr(i, "autoconnect_hash")]) diff --git a/RNS/Reticulum.py b/RNS/Reticulum.py index 9bd96ce4..bbc30346 100755 --- a/RNS/Reticulum.py +++ b/RNS/Reticulum.py @@ -763,8 +763,8 @@ class Reticulum: RNS.log("System interfaces are ready", RNS.LOG_VERBOSE) - def _attach_interface(self, name): - if not Reticulum.__interface_management_enabled: return False + def _attach_interface(self, name, internal_forced=False): + if not internal_forced and not Reticulum.__interface_management_enabled: return False try: interfaces = { iface.name: iface for iface in RNS.Transport.interfaces } if name in interfaces: @@ -791,8 +791,8 @@ class Reticulum: except Exception as e: RNS.log(f"Error while detaching interface \"{name}\": {e}", RNS.LOG_ERROR) return False - def _detach_interface(self, name): - if not Reticulum.__interface_management_enabled: return False + def _detach_interface(self, name, internal_forced=False): + if not internal_forced and not Reticulum.__interface_management_enabled: return False try: interfaces = { iface.name: iface for iface in RNS.Transport.interfaces } if not name in interfaces: @@ -820,8 +820,8 @@ class Reticulum: except Exception as e: RNS.log(f"Error while detaching interface \"{name}\": {e}", RNS.LOG_ERROR); RNS.trace_exception(e) return False - def _reload_interface(self, name): - if not Reticulum.__interface_management_enabled: return False + def _reload_interface(self, name, internal_forced=False): + if not internal_forced and not Reticulum.__interface_management_enabled: return False interfaces = { iface.name: iface for iface in RNS.Transport.interfaces } if not name in interfaces: RNS.log(f"Attempt to reload non-existing interface \"{name}\"", RNS.LOG_WARNING)