From b3a439993d9ac16dd030fc1b68b69a98f220deed Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Wed, 20 Apr 2022 09:59:58 +0200 Subject: [PATCH] Improved rnstatus output --- RNS/Reticulum.py | 9 +++++++-- RNS/Utilities/rnstatus.py | 12 ++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/RNS/Reticulum.py b/RNS/Reticulum.py index ed63df4..8dce164 100755 --- a/RNS/Reticulum.py +++ b/RNS/Reticulum.py @@ -761,7 +761,7 @@ class Reticulum: response = rpc_connection.recv() return response else: - stats = [] + interfaces = [] for interface in RNS.Transport.interfaces: ifstats = {} @@ -800,7 +800,12 @@ class Reticulum: ifstats["status"] = interface.online ifstats["mode"] = interface.mode - stats.append(ifstats) + interfaces.append(ifstats) + + stats = {} + stats["interfaces"] = interfaces + if Reticulum.transport_enabled(): + stats["transport_id"] = RNS.Transport.identity.hash return stats diff --git a/RNS/Utilities/rnstatus.py b/RNS/Utilities/rnstatus.py index 71dea0c..e5b1323 100644 --- a/RNS/Utilities/rnstatus.py +++ b/RNS/Utilities/rnstatus.py @@ -49,18 +49,19 @@ def size_str(num, suffix='B'): def program_setup(configdir, dispall=False, verbosity = 0): reticulum = RNS.Reticulum(configdir = configdir, loglevel = 3+verbosity) - ifstats = None + stats = None try: - ifstats = reticulum.get_interface_stats() + stats = reticulum.get_interface_stats() except Exception as e: pass - if ifstats != None: - for ifstat in ifstats: + if stats != None: + for ifstat in stats["interfaces"]: name = ifstat["name"] if dispall or not (name.startswith("LocalInterface[") or name.startswith("TCPInterface[Client")): print("") + if ifstat["status"]: ss = "Up" else: @@ -117,6 +118,9 @@ def program_setup(configdir, dispall=False, verbosity = 0): print(" Traffic : {txb}↑\n {rxb}↓".format(rxb=size_str(ifstat["rxb"]), txb=size_str(ifstat["txb"]))) + if "transport_id" in stats and stats["transport_id"] != None: + print("\n Transport Instance "+RNS.prettyhexrep(stats["transport_id"])+" running") + print("") else: