diff --git a/RNS/Interfaces/LocalInterface.py b/RNS/Interfaces/LocalInterface.py index 08a410c..445ba28 100644 --- a/RNS/Interfaces/LocalInterface.py +++ b/RNS/Interfaces/LocalInterface.py @@ -70,7 +70,7 @@ class LocalClientInterface(Interface): self.HW_MTU = 262144 self.online = False - if socket_path != None and RNS.vendor.platformutils.use_af_unix(): self.socket_path = f"\0rns/{socket_path}" + if socket_path != None and RNS.Reticulum.get_instance().use_af_unix: self.socket_path = f"\0rns/{socket_path}" else: self.socket_path = None self.IN = True @@ -350,7 +350,7 @@ class LocalServerInterface(Interface): self.online = False self.clients = 0 - if socket_path != None and RNS.vendor.platformutils.use_af_unix(): self.socket_path = f"\0rns/{socket_path}" + if socket_path != None and RNS.Reticulum.get_instance().use_af_unix: self.socket_path = f"\0rns/{socket_path}" else: self.socket_path = None self.IN = True diff --git a/RNS/Reticulum.py b/RNS/Reticulum.py index c112a7f..23d88f6 100755 --- a/RNS/Reticulum.py +++ b/RNS/Reticulum.py @@ -211,7 +211,8 @@ class Reticulum: """ return Reticulum.__instance - def __init__(self,configdir=None, loglevel=None, logdest=None, verbosity=None, require_shared_instance=False): + def __init__(self,configdir=None, loglevel=None, logdest=None, verbosity=None, + require_shared_instance=False, shared_instance_type=None): """ Initialises and starts a Reticulum instance. This must be done before any other operations, and Reticulum will not @@ -263,12 +264,11 @@ class Reticulum: self.local_control_port = 37429 self.local_socket_path = None self.share_instance = True + self.shared_instance_type = shared_instance_type self.rpc_listener = None self.rpc_key = None self.rpc_type = "AF_INET" - - if RNS.vendor.platformutils.use_af_unix(): - self.local_socket_path = "default" + self.use_af_unix = False self.ifac_salt = Reticulum.IFAC_SALT @@ -325,12 +325,11 @@ class Reticulum: self.__apply_config() RNS.log(f"Utilising cryptography backend \"{RNS.Cryptography.Provider.backend()}\"", RNS.LOG_DEBUG) RNS.log(f"Configuration loaded from {self.configpath}", RNS.LOG_VERBOSE) - - RNS.Identity.load_known_destinations() + RNS.Identity.load_known_destinations() RNS.Transport.start(self) - if RNS.vendor.platformutils.use_af_unix(): + if self.use_af_unix: self.rpc_addr = f"\0rns/{self.local_socket_path}/rpc" self.rpc_type = "AF_UNIX" else: @@ -458,6 +457,11 @@ class Reticulum: if option == "instance_name": value = self.config["reticulum"][option] self.local_socket_path = value + if option == "shared_instance_type": + if self.shared_instance_type == None: + value = self.config["reticulum"][option].lower() + if value in ["tcp", "unix"]: + self.shared_instance_type = value if option == "shared_instance_port": value = int(self.config["reticulum"][option]) self.local_interface_port = value @@ -516,6 +520,17 @@ class Reticulum: if RNS.compiled: RNS.log("Reticulum running in compiled mode", RNS.LOG_DEBUG) else: RNS.log("Reticulum running in interpreted mode", RNS.LOG_DEBUG) + + if RNS.vendor.platformutils.use_af_unix(): + if self.shared_instance_type == "tcp": self.use_af_unix = False + else: self.use_af_unix = True + else: + self.shared_instance_type = "tcp" + self.use_af_unix = False + + if self.local_socket_path == None and self.use_af_unix: + self.local_socket_path = "default" + self.__start_local_interface() if self.is_shared_instance or self.is_standalone_instance: @@ -1379,8 +1394,16 @@ instance_name = default # is the case, you can isolate different instances by # specifying a unique set of ports for each: -shared_instance_port = 37428 -instance_control_port = 37429 +# shared_instance_port = 37428 +# instance_control_port = 37429 + + +# If you want to explicitly use TCP for shared instance +# communication, instead of domain sockets, this is also +# possible, by using the following option: + +# shared_instance_type = tcp + # You can configure Reticulum to panic and forcibly close # if an unrecoverable interface error occurs, such as the @@ -1388,7 +1411,7 @@ instance_control_port = 37429 # an optional directive, and can be left out for brevity. # This behaviour is disabled by default. -panic_on_interface_error = No +# panic_on_interface_error = No [logging] diff --git a/RNS/Utilities/rnsd.py b/RNS/Utilities/rnsd.py index c3d4fe7..15ae69c 100755 --- a/RNS/Utilities/rnsd.py +++ b/RNS/Utilities/rnsd.py @@ -117,12 +117,24 @@ share_instance = Yes # If you want to run multiple *different* shared instances # on the same system, you will need to specify different -# shared instance ports for each. The defaults are given -# below, and again, these options can be left out if you -# don't need them. +# instance names for each. On platforms supporting domain +# sockets, this can be done with the instance_name option: -shared_instance_port = 37428 -instance_control_port = 37429 +instance_name = default + +# Some platforms don't support domain sockets, and if that +# is the case, you can isolate different instances by +# specifying a unique set of ports for each: + +# shared_instance_port = 37428 +# instance_control_port = 37429 + + +# If you want to explicitly use TCP for shared instance +# communication, instead of domain sockets, this is also +# possible, by using the following option: + +# shared_instance_type = tcp # On systems where running instances may not have access @@ -154,7 +166,7 @@ instance_control_port = 37429 # an optional directive, and can be left out for brevity. # This behaviour is disabled by default. -panic_on_interface_error = No +# panic_on_interface_error = No # When Transport is enabled, it is possible to allow the @@ -165,7 +177,7 @@ panic_on_interface_error = No # Transport Instance, and printed to the log at startup. # Optional, and disabled by default. -respond_to_probes = No +# respond_to_probes = No [logging] diff --git a/docs/source/using.rst b/docs/source/using.rst index 20260c0..73aab5d 100644 --- a/docs/source/using.rst +++ b/docs/source/using.rst @@ -69,12 +69,12 @@ configuration file is created. The default configuration looks like this: # If you enable Transport, your system will route traffic # for other peers, pass announces and serve path requests. - # This should only be done for systems that are suited to - # act as transport nodes, ie. if they are stationary and + # This should be done for systems that are suited to act + # as transport nodes, ie. if they are stationary and # always-on. This directive is optional and can be removed # for brevity. - enable_transport = False + enable_transport = No # By default, the first program to launch the Reticulum @@ -91,12 +91,24 @@ configuration file is created. The default configuration looks like this: # If you want to run multiple *different* shared instances # on the same system, you will need to specify different - # shared instance ports for each. The defaults are given - # below, and again, these options can be left out if you - # don't need them. + # instance names for each. On platforms supporting domain + # sockets, this can be done with the instance_name option: - shared_instance_port = 37428 - instance_control_port = 37429 + instance_name = default + + # Some platforms don't support domain sockets, and if that + # is the case, you can isolate different instances by + # specifying a unique set of ports for each: + + # shared_instance_port = 37428 + # instance_control_port = 37429 + + + # If you want to explicitly use TCP for shared instance + # communication, instead of domain sockets, this is also + # possible, by using the following option: + + # shared_instance_type = tcp # On systems where running instances may not have access @@ -110,13 +122,25 @@ configuration file is created. The default configuration looks like this: # rpc_key = e5c032d3ec4e64a6aca9927ba8ab73336780f6d71790 + # It is possible to allow remote management of Reticulum + # systems using the various built-in utilities, such as + # rnstatus and rnpath. You will need to specify one or + # more Reticulum Identity hashes for authenticating the + # queries from client programs. For this purpose, you can + # use existing identity files, or generate new ones with + # the rnid utility. + + # enable_remote_management = yes + # remote_management_allowed = 9fb6d773498fb3feda407ed8ef2c3229, 2d882c5586e548d79b5af27bca1776dc + + # You can configure Reticulum to panic and forcibly close # if an unrecoverable interface error occurs, such as the # hardware device for an interface disappearing. This is # an optional directive, and can be left out for brevity. # This behaviour is disabled by default. - panic_on_interface_error = No + # panic_on_interface_error = No # When Transport is enabled, it is possible to allow the @@ -127,7 +151,7 @@ configuration file is created. The default configuration looks like this: # Transport Instance, and printed to the log at startup. # Optional, and disabled by default. - respond_to_probes = No + # respond_to_probes = No [logging]