diff --git a/RNS/Interfaces/Interface.py b/RNS/Interfaces/Interface.py index 2539284..05c5e62 100755 --- a/RNS/Interfaces/Interface.py +++ b/RNS/Interfaces/Interface.py @@ -34,6 +34,8 @@ class Interface: MODE_FULL = 0x01 MODE_POINT_TO_POINT = 0x02 MODE_ACCESS_POINT = 0x03 + MODE_ROAMING = 0x04 + MODE_BOUNDARY = 0x05 def __init__(self): self.rxb = 0 diff --git a/RNS/Reticulum.py b/RNS/Reticulum.py index 6176bce..fe7a4a7 100755 --- a/RNS/Reticulum.py +++ b/RNS/Reticulum.py @@ -343,20 +343,30 @@ class Reticulum: interface_mode = Interface.Interface.MODE_FULL if "interface_mode" in c: + c["interface_mode"] = str(c["interface_mode"]).lower() if c["interface_mode"] == "full": interface_mode = Interface.Interface.MODE_FULL elif c["interface_mode"] == "access_point" or c["interface_mode"] == "accesspoint" or c["interface_mode"] == "ap": interface_mode = Interface.Interface.MODE_ACCESS_POINT elif c["interface_mode"] == "pointtopoint" or c["interface_mode"] == "ptp": interface_mode = Interface.Interface.MODE_POINT_TO_POINT + elif c["interface_mode"] == "roaming": + interface_mode = Interface.Interface.MODE_ROAMING + elif c["interface_mode"] == "boundary": + interface_mode = Interface.Interface.MODE_BOUNDARY elif "mode" in c: + c["mode"] = str(c["mode"]).lower() if c["mode"] == "full": interface_mode = Interface.Interface.MODE_FULL elif c["mode"] == "access_point" or c["mode"] == "accesspoint" or c["mode"] == "ap": interface_mode = Interface.Interface.MODE_ACCESS_POINT elif c["mode"] == "pointtopoint" or c["mode"] == "ptp": interface_mode = Interface.Interface.MODE_POINT_TO_POINT + elif c["mode"] == "roaming": + interface_mode = Interface.Interface.MODE_ROAMING + elif c["mode"] == "boundary": + interface_mode = Interface.Interface.MODE_BOUNDARY ifac_size = None if "ifac_size" in c: diff --git a/RNS/Transport.py b/RNS/Transport.py index 95f8fca..8e7d3f9 100755 --- a/RNS/Transport.py +++ b/RNS/Transport.py @@ -53,11 +53,12 @@ class Transport: Maximum amount of hops that Reticulum will transport a packet. """ - PATHFINDER_R = 1 # Retransmit retries - PATHFINDER_G = 5 # Retry grace period - PATHFINDER_RW = 0.5 # Random window for announce rebroadcast - PATHFINDER_E = 60*60*24*7 # Path expiration of one week - AP_PATH_TIME = 60*60*24 # Path expiration of one day for Access Point paths + PATHFINDER_R = 1 # Retransmit retries + PATHFINDER_G = 5 # Retry grace period + PATHFINDER_RW = 0.5 # Random window for announce rebroadcast + PATHFINDER_E = 60*60*24*7 # Path expiration of one week + AP_PATH_TIME = 60*60*24 # Path expiration of one day for Access Point paths + ROAMING_PATH_TIME = 60*60*6 # Path expiration of 6 hours for Roaming paths # TODO: Calculate an optimal number for this in # various situations @@ -575,7 +576,30 @@ class Transport: if interface.mode == RNS.Interfaces.Interface.Interface.MODE_ACCESS_POINT: RNS.log("Blocking announce broadcast on "+str(interface)+" due to AP mode", RNS.LOG_EXTREME) should_transmit = False - + + elif interface.mode == RNS.Interfaces.Interface.Interface.MODE_ROAMING: + from_interface = Transport.next_hop_interface(packet.destination_hash) + if from_interface == None or not hasattr(from_interface, "mode"): + RNS.log("Blocking announce broadcast on "+str(interface)+" since next hop interface is non-existing or has no mode configured", RNS.LOG_EXTREME) + should_transmit = False + else: + if from_interface.mode == RNS.Interfaces.Interface.Interface.MODE_ROAMING: + RNS.log("Blocking announce broadcast on "+str(interface)+" due to roaming-mode next-hop interface", RNS.LOG_EXTREME) + should_transmit = False + elif from_interface.mode == RNS.Interfaces.Interface.Interface.MODE_BOUNDARY: + RNS.log("Blocking announce broadcast on "+str(interface)+" due to boundary-mode next-hop interface", RNS.LOG_EXTREME) + should_transmit = False + + elif interface.mode == RNS.Interfaces.Interface.Interface.MODE_BOUNDARY: + from_interface = Transport.next_hop_interface(packet.destination_hash) + if from_interface == None or not hasattr(from_interface, "mode"): + RNS.log("Blocking announce broadcast on "+str(interface)+" since next hop interface is non-existing or has no mode configured", RNS.LOG_EXTREME) + should_transmit = False + else: + if from_interface.mode == RNS.Interfaces.Interface.Interface.MODE_ROAMING: + RNS.log("Blocking announce broadcast on "+str(interface)+" due to roaming-mode next-hop interface", RNS.LOG_EXTREME) + should_transmit = False + else: # Currently, annouces originating locally are always # allowed, and do not conform to bandwidth caps. @@ -1080,6 +1104,8 @@ class Transport: if packet.receiving_interface.mode == RNS.Interfaces.Interface.Interface.MODE_ACCESS_POINT: expires = now + Transport.AP_PATH_TIME + elif packet.receiving_interface.mode == RNS.Interfaces.Interface.Interface.MODE_ROAMING: + expires = now + Transport.ROAMING_PATH_TIME else: expires = now + Transport.PATHFINDER_E diff --git a/RNS/Utilities/rnstatus.py b/RNS/Utilities/rnstatus.py index b9492b9..e7e5b3c 100644 --- a/RNS/Utilities/rnstatus.py +++ b/RNS/Utilities/rnstatus.py @@ -71,6 +71,10 @@ def program_setup(configdir, dispall=False, verbosity = 0): modestr = "Access Point" elif ifstat["mode"] == RNS.Interfaces.Interface.Interface.MODE_POINT_TO_POINT: modestr = "Point-to-Point" + elif ifstat["mode"] == RNS.Interfaces.Interface.Interface.MODE_ROAMING: + modestr = "Roaming" + elif ifstat["mode"] == RNS.Interfaces.Interface.Interface.MODE_BOUNDARY: + modestr = "Boundary" else: modestr = "Full" diff --git a/RNS/_version.py b/RNS/_version.py index a8d4557..d7b30e1 100644 --- a/RNS/_version.py +++ b/RNS/_version.py @@ -1 +1 @@ -__version__ = "0.3.5" +__version__ = "0.3.6"