From 25127cd3c9fec29005aee30e31799853b8a5792c Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Thu, 21 Nov 2024 12:22:09 +0100 Subject: [PATCH] Internal interface config handling for PipeInterface --- RNS/Interfaces/PipeInterface.py | 15 ++++++++++++--- RNS/Reticulum.py | 29 ++--------------------------- 2 files changed, 14 insertions(+), 30 deletions(-) diff --git a/RNS/Interfaces/PipeInterface.py b/RNS/Interfaces/PipeInterface.py index ffe5c9e..296d195 100644 --- a/RNS/Interfaces/PipeInterface.py +++ b/RNS/Interfaces/PipeInterface.py @@ -46,16 +46,25 @@ class HDLC(): class PipeInterface(Interface): MAX_CHUNK = 32768 BITRATE_GUESS = 1*1000*1000 + DEFAULT_IFAC_SIZE = 8 owner = None command = None - def __init__(self, owner, name, command, respawn_delay): + def __init__(self, owner, configuration): + super().__init__() + + c = configuration + name = c["name"] + command = c["command"] if "command" in c else None + respawn_delay = c.as_float("respawn_delay") if "respawn_delay" in c else None + + if command == None: + raise ValueError("No command specified for PipeInterface") + if respawn_delay == None: respawn_delay = 5 - super().__init__() - self.HW_MTU = 1064 self.owner = owner diff --git a/RNS/Reticulum.py b/RNS/Reticulum.py index 0a071e0..75dd6bc 100755 --- a/RNS/Reticulum.py +++ b/RNS/Reticulum.py @@ -619,33 +619,8 @@ class Reticulum: interface_post_init(interface) if c["type"] == "PipeInterface": - command = c["command"] if "command" in c else None - respawn_delay = c.as_float("respawn_delay") if "respawn_delay" in c else None - - if command == None: - raise ValueError("No command specified for PipeInterface") - - interface = PipeInterface.PipeInterface( - RNS.Transport, - name, - command, - respawn_delay, - ) - - if "outgoing" in c and c.as_bool("outgoing") == False: - interface.OUT = False - else: - interface.OUT = True - - interface.mode = interface_mode - - 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 = 8 + interface = PipeInterface.PipeInterface(RNS.Transport, interface_config) + interface_post_init(interface) if c["type"] == "KISSInterface": preamble = int(c["preamble"]) if "preamble" in c else None