Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom bind addresses for share_instance_port and instance_control_port #625

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions RNS/Interfaces/LocalInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def __str__(self):

class LocalServerInterface(Interface):

def __init__(self, owner, bindport=None):
def __init__(self, owner, bindaddr="127.0.0.1", bindport=None):
super().__init__()
self.online = False
self.clients = 0
Expand All @@ -305,7 +305,7 @@ def __init__(self, owner, bindport=None):

if (bindport != None):
self.receives = True
self.bind_ip = "127.0.0.1"
self.bind_ip = bindaddr
self.bind_port = bindport

def handlerFactory(callback):
Expand Down
24 changes: 23 additions & 1 deletion RNS/Reticulum.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,14 @@ def __init__(self,configdir=None, loglevel=None, logdest=None, verbosity=None, r
Reticulum.panic_on_interface_error = False

self.local_interface_port = 37428
self.share_instance_addr = "127.0.0.1"


self.local_control_port = 37429
self.instance_control_addr = "127.0.0.1"



self.share_instance = True
self.rpc_listener = None
self.rpc_key = None
Expand Down Expand Up @@ -289,7 +296,7 @@ def __init__(self,configdir=None, loglevel=None, logdest=None, verbosity=None, r

RNS.Transport.start(self)

self.rpc_addr = ("127.0.0.1", self.local_control_port)
self.rpc_addr = (self.instance_control_addr, self.local_control_port)
if self.rpc_key == None:
self.rpc_key = RNS.Identity.full_hash(RNS.Transport.identity.get_private_key())

Expand Down Expand Up @@ -328,6 +335,7 @@ def __start_local_interface(self):
try:
interface = LocalInterface.LocalServerInterface(
RNS.Transport,
self.share_instance_addr,
self.local_interface_port
)
interface.OUT = True
Expand Down Expand Up @@ -402,12 +410,26 @@ def __apply_config(self):
if option == "share_instance":
value = self.config["reticulum"].as_bool(option)
self.share_instance = value

if option == "shared_instance_address":
value = self.config["reticulum"][option]
self.share_instance_addr = value
if option == "shared_instance_port":
value = int(self.config["reticulum"][option])
self.local_interface_port = value


if option == "instance_control_addr":
value = self.config["reticulum"][option]
self.instance_control_addr = value
if option == "instance_control_port":
value = int(self.config["reticulum"][option])
self.local_control_port = value





if option == "rpc_key":
try:
value = bytes.fromhex(self.config["reticulum"][option])
Expand Down