mirror of
https://github.com/markqvist/Reticulum.git
synced 2024-11-25 07:00:17 +00:00
Internal interface config handling for TCPServerInterface
This commit is contained in:
parent
18e0dbddfa
commit
c9d744f88a
@ -419,6 +419,7 @@ class TCPClientInterface(Interface):
|
|||||||
|
|
||||||
class TCPServerInterface(Interface):
|
class TCPServerInterface(Interface):
|
||||||
BITRATE_GUESS = 10*1000*1000
|
BITRATE_GUESS = 10*1000*1000
|
||||||
|
DEFAULT_IFAC_SIZE = 16
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_address_for_if(name, bind_port, prefer_ipv6=False):
|
def get_address_for_if(name, bind_port, prefer_ipv6=False):
|
||||||
@ -451,7 +452,20 @@ class TCPServerInterface(Interface):
|
|||||||
raise SystemError(f"No suitable kernel interface available for address \"{name}\" for TCPServerInterface to bind to")
|
raise SystemError(f"No suitable kernel interface available for address \"{name}\" for TCPServerInterface to bind to")
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, owner, name, device=None, bindip=None, bindport=None, i2p_tunneled=False, prefer_ipv6=False):
|
# def __init__(self, owner, name, device=None, bindip=None, bindport=None, i2p_tunneled=False, prefer_ipv6=False):
|
||||||
|
def __init__(self, owner, configuration):
|
||||||
|
c = configuration
|
||||||
|
name = c["name"]
|
||||||
|
device = c["device"] if "device" in c else None
|
||||||
|
port = int(c["port"]) if "port" in c else None
|
||||||
|
bindip = c["listen_ip"] if "listen_ip" in c else None
|
||||||
|
bindport = int(c["listen_port"]) if "listen_port" in c else None
|
||||||
|
i2p_tunneled = c.as_bool("i2p_tunneled") if "i2p_tunneled" in c else False
|
||||||
|
prefer_ipv6 = c.as_bool("prefer_ipv6") if "prefer_ipv6" in c else False
|
||||||
|
|
||||||
|
if port != None:
|
||||||
|
bindport = port
|
||||||
|
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
self.HW_MTU = 1064
|
self.HW_MTU = 1064
|
||||||
|
@ -586,44 +586,12 @@ class Reticulum:
|
|||||||
interface_post_init(interface)
|
interface_post_init(interface)
|
||||||
|
|
||||||
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
|
|
||||||
i2p_tunneled = c.as_bool("i2p_tunneled") if "i2p_tunneled" in c else False
|
|
||||||
prefer_ipv6 = c.as_bool("prefer_ipv6") if "prefer_ipv6" in c else False
|
|
||||||
|
|
||||||
if port != None:
|
|
||||||
listen_port = port
|
|
||||||
|
|
||||||
interface = TCPInterface.TCPServerInterface(
|
|
||||||
RNS.Transport,
|
|
||||||
name,
|
|
||||||
device,
|
|
||||||
listen_ip,
|
|
||||||
listen_port,
|
|
||||||
i2p_tunneled,
|
|
||||||
prefer_ipv6,
|
|
||||||
)
|
|
||||||
|
|
||||||
if "outgoing" in c and c.as_bool("outgoing") == False:
|
|
||||||
interface.OUT = False
|
|
||||||
else:
|
|
||||||
interface.OUT = True
|
|
||||||
|
|
||||||
if interface_mode == Interface.Interface.MODE_ACCESS_POINT:
|
if interface_mode == Interface.Interface.MODE_ACCESS_POINT:
|
||||||
RNS.log(str(interface)+" does not support Access Point mode, reverting to default mode: Full", RNS.LOG_WARNING)
|
RNS.log(str(interface)+" does not support Access Point mode, reverting to default mode: Full", RNS.LOG_WARNING)
|
||||||
interface_mode = Interface.Interface.MODE_FULL
|
interface_mode = Interface.Interface.MODE_FULL
|
||||||
|
|
||||||
interface.mode = interface_mode
|
interface = TCPInterface.TCPServerInterface(RNS.Transport, interface_config)
|
||||||
|
interface_post_init(interface)
|
||||||
interface.announce_cap = announce_cap
|
|
||||||
if configured_bitrate:
|
|
||||||
interface.bitrate = configured_bitrate
|
|
||||||
if ifac_size != None:
|
|
||||||
interface.ifac_size = ifac_size
|
|
||||||
else:
|
|
||||||
interface.ifac_size = 16
|
|
||||||
|
|
||||||
if c["type"] == "TCPClientInterface":
|
if c["type"] == "TCPClientInterface":
|
||||||
kiss_framing = False
|
kiss_framing = False
|
||||||
|
Loading…
Reference in New Issue
Block a user