mirror of
https://github.com/liberatedsystems/openCom-Companion.git
synced 2024-11-25 14:50:37 +01:00
Re-init AutoInterface periodically if no suitable PHY IFs exist at start
This commit is contained in:
parent
a0a6745b35
commit
c77fb4ce20
@ -150,6 +150,7 @@ class SidebandCore():
|
||||
self.saving_configuration = False
|
||||
self.last_lxmf_announce = 0
|
||||
self.last_if_change_announce = 0
|
||||
self.interface_local_adding = False
|
||||
self.next_auto_announce = time.time() + 60*(random.random()*(SidebandCore.AUTO_ANNOUNCE_RANDOM_MAX-SidebandCore.AUTO_ANNOUNCE_RANDOM_MIN))
|
||||
|
||||
self.getstate_cache = {}
|
||||
@ -1808,6 +1809,19 @@ class SidebandCore():
|
||||
|
||||
self.interface_local.had_peers = have_peers
|
||||
|
||||
if len(self.interface_local.adopted_interfaces) == 0:
|
||||
if not self.interface_local_adding:
|
||||
RNS.log("No suitable interfaces on AutoInterface, scheduling re-init", RNS.LOG_DEBUG)
|
||||
if self.interface_local in RNS.Transport.interfaces:
|
||||
RNS.Transport.interfaces.remove(self.interface_local)
|
||||
del self.interface_local
|
||||
self.interface_local = None
|
||||
def job():
|
||||
self.__add_localinterface(delay=60)
|
||||
threading.Thread(target=job, daemon=True).start()
|
||||
else:
|
||||
pass
|
||||
|
||||
for interface in RNS.Transport.interfaces:
|
||||
if not hasattr(self, "interface_local") or interface != self.interface_local:
|
||||
if hasattr(interface, "was_online"):
|
||||
@ -1973,40 +1987,11 @@ class SidebandCore():
|
||||
if self.config["telemetry_enabled"]:
|
||||
self.latest_telemetry = self.run_telemetry()
|
||||
|
||||
def __start_jobs_immediate(self):
|
||||
if self.log_verbose:
|
||||
selected_level = 7
|
||||
else:
|
||||
selected_level = 2
|
||||
def __add_localinterface(self, delay=None):
|
||||
self.interface_local_adding = True
|
||||
if delay:
|
||||
time.sleep(delay)
|
||||
|
||||
self.setstate("init.loadingstate", "Substantiating Reticulum")
|
||||
self.reticulum = RNS.Reticulum(configdir=self.rns_configdir, loglevel=selected_level)
|
||||
|
||||
if self.is_service:
|
||||
self.__start_rpc_listener()
|
||||
|
||||
if RNS.vendor.platformutils.get_platform() == "android":
|
||||
# TODO: Just log to console for, but add option to export log
|
||||
# files at some point.
|
||||
# if self.config["debug"]:
|
||||
# self.reticulum.logdest = RNS.LOG_FILE
|
||||
# if not self.reticulum.is_connected_to_shared_instance:
|
||||
# self.reticulum.logfile = self.log_dir+"sideband_service.log"
|
||||
# else:
|
||||
# self.reticulum.logfile = self.log_dir+"sideband_core.log"
|
||||
|
||||
if not self.reticulum.is_connected_to_shared_instance:
|
||||
RNS.log("Running as master or standalone instance, adding interfaces")
|
||||
|
||||
self.interface_local = None
|
||||
self.interface_tcp = None
|
||||
self.interface_i2p = None
|
||||
self.interface_rnode = None
|
||||
self.interface_modem = None
|
||||
self.interface_serial = None
|
||||
|
||||
if self.config["connect_local"]:
|
||||
self.setstate("init.loadingstate", "Discovering Topography")
|
||||
try:
|
||||
RNS.log("Adding Auto Interface...", RNS.LOG_DEBUG)
|
||||
if self.config["connect_local_groupid"] == "":
|
||||
@ -2046,10 +2031,49 @@ class SidebandCore():
|
||||
|
||||
self.reticulum._add_interface(autointerface, mode = if_mode, ifac_netname = ifac_netname, ifac_netkey = ifac_netkey)
|
||||
self.interface_local = autointerface
|
||||
self.interface_local_adding = False
|
||||
|
||||
except Exception as e:
|
||||
RNS.log("Error while adding AutoInterface. The contained exception was: "+str(e))
|
||||
self.interface_local = None
|
||||
self.interface_local_adding = False
|
||||
|
||||
|
||||
def __start_jobs_immediate(self):
|
||||
if self.log_verbose:
|
||||
selected_level = 7
|
||||
else:
|
||||
selected_level = 2
|
||||
|
||||
self.setstate("init.loadingstate", "Substantiating Reticulum")
|
||||
self.reticulum = RNS.Reticulum(configdir=self.rns_configdir, loglevel=selected_level)
|
||||
|
||||
if self.is_service:
|
||||
self.__start_rpc_listener()
|
||||
|
||||
if RNS.vendor.platformutils.get_platform() == "android":
|
||||
# TODO: Just log to console for, but add option to export log
|
||||
# files at some point.
|
||||
# if self.config["debug"]:
|
||||
# self.reticulum.logdest = RNS.LOG_FILE
|
||||
# if not self.reticulum.is_connected_to_shared_instance:
|
||||
# self.reticulum.logfile = self.log_dir+"sideband_service.log"
|
||||
# else:
|
||||
# self.reticulum.logfile = self.log_dir+"sideband_core.log"
|
||||
|
||||
if not self.reticulum.is_connected_to_shared_instance:
|
||||
RNS.log("Running as master or standalone instance, adding interfaces")
|
||||
|
||||
self.interface_local = None
|
||||
self.interface_tcp = None
|
||||
self.interface_i2p = None
|
||||
self.interface_rnode = None
|
||||
self.interface_modem = None
|
||||
self.interface_serial = None
|
||||
|
||||
if self.config["connect_local"]:
|
||||
self.setstate("init.loadingstate", "Discovering Topography")
|
||||
self.__add_localinterface()
|
||||
|
||||
if self.config["connect_tcp"]:
|
||||
self.setstate("init.loadingstate", "Connecting TCP Tunnel")
|
||||
|
Loading…
Reference in New Issue
Block a user