mirror of
https://github.com/markqvist/Reticulum.git
synced 2026-07-25 09:18:09 -07:00
Added autoconnect_discovered_mode and autoconnect_announces_to_internal options
This commit is contained in:
+5
-2
@@ -722,12 +722,15 @@ class InterfaceDiscovery():
|
||||
RNS.log(f"Auto-connecting discovered {interface_type} {interface_name}")
|
||||
interface.autoconnect_hash = endpoint_hash
|
||||
interface.autoconnect_source = info["network_id"]
|
||||
mode = RNS.Interfaces.Interface.Interface.MODE_GATEWAY if RNS.Reticulum.transport_enabled() else None
|
||||
if RNS.Reticulum.autoconnect_interface_mode(): mode = RNS.Reticulum.autoconnect_interface_mode()
|
||||
else: mode = RNS.Interfaces.Interface.Interface.MODE_GATEWAY if RNS.Reticulum.transport_enabled() else None
|
||||
internal_a = True if RNS.Reticulum.autoconnect_announces_to_internal() else None
|
||||
ar_target = RNS.Reticulum.get_instance()._default_ar_target() if RNS.Reticulum.transport_enabled() else None
|
||||
ar_penalty = RNS.Reticulum.get_instance()._default_ar_penalty() if RNS.Reticulum.transport_enabled() else None
|
||||
ar_grace = RNS.Reticulum.get_instance()._default_ar_grace() if RNS.Reticulum.transport_enabled() else None
|
||||
RNS.Reticulum.get_instance()._add_interface(interface, mode=mode, ifac_netname=ifac_netname, ifac_netkey=ifac_netkey, configured_bitrate=5E6,
|
||||
announce_rate_target=ar_target, announce_rate_grace=ar_grace, announce_rate_penalty=ar_penalty)
|
||||
announce_rate_target=ar_target, announce_rate_grace=ar_grace, announce_rate_penalty=ar_penalty,
|
||||
announces_to_internal=internal_a)
|
||||
self.monitor_interface(interface)
|
||||
|
||||
except Exception as e:
|
||||
|
||||
@@ -261,6 +261,8 @@ class Reticulum:
|
||||
Reticulum.__discovery_enabled = False
|
||||
Reticulum.__discover_interfaces = False
|
||||
Reticulum.__autoconnect_discovered_interfaces = False
|
||||
Reticulum.__autoconnect_interface_mode = None
|
||||
Reticulum.__autoconnect_announces_to_internal = None
|
||||
Reticulum.__required_discovery_value = None
|
||||
Reticulum.__publish_blackhole = False
|
||||
Reticulum.__blackhole_update_interval = RNS.Discovery.BlackholeUpdater.UPDATE_INTERVAL
|
||||
@@ -608,6 +610,25 @@ class Reticulum:
|
||||
v = self.config["reticulum"].as_int(option)
|
||||
if v > 0: Reticulum.__autoconnect_discovered_interfaces = v
|
||||
|
||||
if option == "autoconnect_discovered_mode":
|
||||
v = None; dmode = str(self.config["reticulum"]["autoconnect_discovered_mode"]).lower()
|
||||
if dmode == "full": v = Interface.Interface.MODE_FULL
|
||||
elif dmode == "access_point": v = Interface.Interface.MODE_ACCESS_POINT
|
||||
elif dmode == "accesspoint": v = Interface.Interface.MODE_ACCESS_POINT
|
||||
elif dmode == "ap": v = Interface.Interface.MODE_ACCESS_POINT
|
||||
elif dmode == "pointtopoint": v = Interface.Interface.MODE_POINT_TO_POINT
|
||||
elif dmode == "ptp": v = Interface.Interface.MODE_POINT_TO_POINT
|
||||
elif dmode == "roaming": v = Interface.Interface.MODE_ROAMING
|
||||
elif dmode == "boundary": v = Interface.Interface.MODE_BOUNDARY
|
||||
elif dmode == "gateway": v = Interface.Interface.MODE_GATEWAY
|
||||
elif dmode == "gw": v = Interface.Interface.MODE_GATEWAY
|
||||
elif dmode == "internal": v = Interface.Interface.MODE_INTERNAL
|
||||
if v != None: Reticulum.__autoconnect_interface_mode = v
|
||||
|
||||
if option == "autoconnect_announces_to_internal":
|
||||
v = self.config["reticulum"].as_bool(option)
|
||||
if v > 0: Reticulum.__autoconnect_announces_to_internal = v
|
||||
|
||||
if option == "default_ar_target":
|
||||
v = self.config["reticulum"].as_int(option)
|
||||
if v == 0: Reticulum.__default_ar_target = None
|
||||
@@ -1446,6 +1467,7 @@ class Reticulum:
|
||||
ifstats["pr_burst_activated"] = interface.ic_pr_burst_activated
|
||||
ifstats["status"] = interface.online
|
||||
ifstats["mode"] = interface.mode
|
||||
ifstats["announces_to_internal"] = interface.announces_to_internal
|
||||
|
||||
interfaces.append(ifstats)
|
||||
|
||||
@@ -1807,6 +1829,14 @@ class Reticulum:
|
||||
def should_autoconnect_discovered_interfaces():
|
||||
return Reticulum.__autoconnect_discovered_interfaces > 0
|
||||
|
||||
@staticmethod
|
||||
def autoconnect_interface_mode():
|
||||
return Reticulum.__autoconnect_interface_mode
|
||||
|
||||
@staticmethod
|
||||
def autoconnect_announces_to_internal():
|
||||
return Reticulum.__autoconnect_announces_to_internal
|
||||
|
||||
@staticmethod
|
||||
def max_autoconnected_interfaces():
|
||||
return Reticulum.__autoconnect_discovered_interfaces
|
||||
|
||||
@@ -217,6 +217,19 @@ instance_name = default
|
||||
|
||||
# panic_on_interface_error = no
|
||||
|
||||
# You can specify which mode discovered interfaces should
|
||||
# be created with when auto-connecting.
|
||||
|
||||
# autoconnect_discovered_mode = gw
|
||||
|
||||
|
||||
# It is possible to allow announces from auto-connected
|
||||
# interfaces to propagate announces to internal-mode
|
||||
# interfaces, even if the auto-connected interface's mode
|
||||
# would normally not allow for this.
|
||||
|
||||
# autoconnect_announces_to_internal = yes
|
||||
|
||||
|
||||
# When Transport is enabled, it is possible to allow the
|
||||
# Transport Instance to respond to probe requests from
|
||||
|
||||
@@ -425,7 +425,7 @@ def program_setup(configdir, dispall=False, verbosity=0, name_filter=None, json=
|
||||
elif ifstat["mode"] == RNS.Interfaces.Interface.Interface.MODE_GATEWAY: modestr = "Gateway"
|
||||
elif ifstat["mode"] == RNS.Interfaces.Interface.Interface.MODE_INTERNAL: modestr = "Internal"
|
||||
else: modestr = "Full"
|
||||
|
||||
if "announces_to_internal" in ifstat and ifstat["announces_to_internal"]: modestr += " (a>i)"
|
||||
|
||||
if ifstat["clients"] != None:
|
||||
clients = ifstat["clients"]
|
||||
@@ -471,7 +471,7 @@ def program_setup(configdir, dispall=False, verbosity=0, name_filter=None, json=
|
||||
print(" "+clients_string)
|
||||
|
||||
if not (name.startswith("Shared Instance[") or name.startswith("TCPInterface[Client") or name.startswith("LocalInterface[")):
|
||||
print(" Mode : {mode}".format(mode=modestr))
|
||||
print(f" Mode : {modestr}")
|
||||
|
||||
if "bitrate" in ifstat and ifstat["bitrate"] != None:
|
||||
print(" Rate : {ss}".format(ss=speed_str(ifstat["bitrate"])))
|
||||
|
||||
Reference in New Issue
Block a user