mirror of
https://github.com/markqvist/Reticulum.git
synced 2024-11-14 10:10:13 +00:00
Added config options for TCP server interface binding to network interface instead of IP.
This commit is contained in:
parent
6382409194
commit
2b8b95da2b
@ -1,6 +1,7 @@
|
|||||||
from .Interface import Interface
|
from .Interface import Interface
|
||||||
import socketserver
|
import socketserver
|
||||||
import threading
|
import threading
|
||||||
|
import netifaces
|
||||||
import socket
|
import socket
|
||||||
import time
|
import time
|
||||||
import sys
|
import sys
|
||||||
@ -127,12 +128,21 @@ class TCPClientInterface(Interface):
|
|||||||
|
|
||||||
|
|
||||||
class TCPServerInterface(Interface):
|
class TCPServerInterface(Interface):
|
||||||
|
@staticmethod
|
||||||
|
def get_address_for_if(name):
|
||||||
|
return netifaces.ifaddresses(name)[netifaces.AF_INET][0]['addr']
|
||||||
|
|
||||||
def __init__(self, owner, name, bindip=None, bindport=None):
|
def get_broadcast_for_if(name):
|
||||||
|
return netifaces.ifaddresses(name)[netifaces.AF_INET][0]['broadcast']
|
||||||
|
|
||||||
|
def __init__(self, owner, name, device=None, bindip=None, bindport=None):
|
||||||
self.IN = True
|
self.IN = True
|
||||||
self.OUT = False
|
self.OUT = False
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|
||||||
|
if device != None:
|
||||||
|
bindip = TCPServerInterface.get_address_for_if(device)
|
||||||
|
|
||||||
if (bindip != None and bindport != None):
|
if (bindip != None and bindport != None):
|
||||||
self.receives = True
|
self.receives = True
|
||||||
self.bind_ip = bindip
|
self.bind_ip = bindip
|
||||||
|
@ -249,11 +249,20 @@ class Reticulum:
|
|||||||
|
|
||||||
|
|
||||||
if c["type"] == "TCPServerInterface":
|
if c["type"] == "TCPServerInterface":
|
||||||
|
device = c["device"] if "device" in c else None
|
||||||
|
port = int(c["port"]) if "port" in c else None
|
||||||
|
listen_ip = c["listen_ip"] if "listen_ip" in c else None
|
||||||
|
listen_port = int(c["listen_port"]) if "listen_port" in c else None
|
||||||
|
|
||||||
|
if port != None:
|
||||||
|
listen_port = port
|
||||||
|
|
||||||
interface = TCPInterface.TCPServerInterface(
|
interface = TCPInterface.TCPServerInterface(
|
||||||
RNS.Transport,
|
RNS.Transport,
|
||||||
name,
|
name,
|
||||||
c["listen_ip"],
|
device,
|
||||||
int(c["listen_port"])
|
listen_ip,
|
||||||
|
listen_port
|
||||||
)
|
)
|
||||||
|
|
||||||
if "outgoing" in c and c.as_bool("outgoing") == True:
|
if "outgoing" in c and c.as_bool("outgoing") == True:
|
||||||
|
Loading…
Reference in New Issue
Block a user