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}")
|
RNS.log(f"Auto-connecting discovered {interface_type} {interface_name}")
|
||||||
interface.autoconnect_hash = endpoint_hash
|
interface.autoconnect_hash = endpoint_hash
|
||||||
interface.autoconnect_source = info["network_id"]
|
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_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_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
|
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,
|
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)
|
self.monitor_interface(interface)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@@ -261,6 +261,8 @@ class Reticulum:
|
|||||||
Reticulum.__discovery_enabled = False
|
Reticulum.__discovery_enabled = False
|
||||||
Reticulum.__discover_interfaces = False
|
Reticulum.__discover_interfaces = False
|
||||||
Reticulum.__autoconnect_discovered_interfaces = False
|
Reticulum.__autoconnect_discovered_interfaces = False
|
||||||
|
Reticulum.__autoconnect_interface_mode = None
|
||||||
|
Reticulum.__autoconnect_announces_to_internal = None
|
||||||
Reticulum.__required_discovery_value = None
|
Reticulum.__required_discovery_value = None
|
||||||
Reticulum.__publish_blackhole = False
|
Reticulum.__publish_blackhole = False
|
||||||
Reticulum.__blackhole_update_interval = RNS.Discovery.BlackholeUpdater.UPDATE_INTERVAL
|
Reticulum.__blackhole_update_interval = RNS.Discovery.BlackholeUpdater.UPDATE_INTERVAL
|
||||||
@@ -608,6 +610,25 @@ class Reticulum:
|
|||||||
v = self.config["reticulum"].as_int(option)
|
v = self.config["reticulum"].as_int(option)
|
||||||
if v > 0: Reticulum.__autoconnect_discovered_interfaces = v
|
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":
|
if option == "default_ar_target":
|
||||||
v = self.config["reticulum"].as_int(option)
|
v = self.config["reticulum"].as_int(option)
|
||||||
if v == 0: Reticulum.__default_ar_target = None
|
if v == 0: Reticulum.__default_ar_target = None
|
||||||
@@ -1446,6 +1467,7 @@ class Reticulum:
|
|||||||
ifstats["pr_burst_activated"] = interface.ic_pr_burst_activated
|
ifstats["pr_burst_activated"] = interface.ic_pr_burst_activated
|
||||||
ifstats["status"] = interface.online
|
ifstats["status"] = interface.online
|
||||||
ifstats["mode"] = interface.mode
|
ifstats["mode"] = interface.mode
|
||||||
|
ifstats["announces_to_internal"] = interface.announces_to_internal
|
||||||
|
|
||||||
interfaces.append(ifstats)
|
interfaces.append(ifstats)
|
||||||
|
|
||||||
@@ -1807,6 +1829,14 @@ class Reticulum:
|
|||||||
def should_autoconnect_discovered_interfaces():
|
def should_autoconnect_discovered_interfaces():
|
||||||
return Reticulum.__autoconnect_discovered_interfaces > 0
|
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
|
@staticmethod
|
||||||
def max_autoconnected_interfaces():
|
def max_autoconnected_interfaces():
|
||||||
return Reticulum.__autoconnect_discovered_interfaces
|
return Reticulum.__autoconnect_discovered_interfaces
|
||||||
|
|||||||
@@ -217,6 +217,19 @@ instance_name = default
|
|||||||
|
|
||||||
# panic_on_interface_error = no
|
# 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
|
# When Transport is enabled, it is possible to allow the
|
||||||
# Transport Instance to respond to probe requests from
|
# 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_GATEWAY: modestr = "Gateway"
|
||||||
elif ifstat["mode"] == RNS.Interfaces.Interface.Interface.MODE_INTERNAL: modestr = "Internal"
|
elif ifstat["mode"] == RNS.Interfaces.Interface.Interface.MODE_INTERNAL: modestr = "Internal"
|
||||||
else: modestr = "Full"
|
else: modestr = "Full"
|
||||||
|
if "announces_to_internal" in ifstat and ifstat["announces_to_internal"]: modestr += " (a>i)"
|
||||||
|
|
||||||
if ifstat["clients"] != None:
|
if ifstat["clients"] != None:
|
||||||
clients = ifstat["clients"]
|
clients = ifstat["clients"]
|
||||||
@@ -471,7 +471,7 @@ def program_setup(configdir, dispall=False, verbosity=0, name_filter=None, json=
|
|||||||
print(" "+clients_string)
|
print(" "+clients_string)
|
||||||
|
|
||||||
if not (name.startswith("Shared Instance[") or name.startswith("TCPInterface[Client") or name.startswith("LocalInterface[")):
|
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:
|
if "bitrate" in ifstat and ifstat["bitrate"] != None:
|
||||||
print(" Rate : {ss}".format(ss=speed_str(ifstat["bitrate"])))
|
print(" Rate : {ss}".format(ss=speed_str(ifstat["bitrate"])))
|
||||||
|
|||||||
@@ -1220,6 +1220,12 @@ The configuration snippet below contains an example of setting these additional
|
|||||||
network_identity = ~/.reticulum/storage/identities/my_network
|
network_identity = ~/.reticulum/storage/identities/my_network
|
||||||
...
|
...
|
||||||
|
|
||||||
|
For more fine-grained control over how discovered interfaces are auto-connected, additional options are provided for configuraiton. These are not necessary to set in most cases, but can be useful in certain situations.
|
||||||
|
|
||||||
|
* The ``autoconnect_discovered_mode`` options specifies which mode discovered interfaces should be created with when auto-connecting.
|
||||||
|
|
||||||
|
* The ``autoconnect_announces_to_internal`` option allows you to specify that auto-connected interfaces should propagate announces to ``internal`` mode interfaces, even if the auto-connected interface's mode would normally not allow for this.
|
||||||
|
|
||||||
Remote Management
|
Remote Management
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user