From 874d76b3433b1173c568439231813e788d889563 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Mon, 18 Sep 2023 15:45:55 +0200 Subject: [PATCH] Added Transport Instance uptime to rnstatut output --- RNS/Reticulum.py | 1 + RNS/Transport.py | 8 +++++--- RNS/Utilities/rnstatus.py | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/RNS/Reticulum.py b/RNS/Reticulum.py index 44a2e2b..29587c8 100755 --- a/RNS/Reticulum.py +++ b/RNS/Reticulum.py @@ -1146,6 +1146,7 @@ class Reticulum: stats["interfaces"] = interfaces if Reticulum.transport_enabled(): stats["transport_id"] = RNS.Transport.identity.hash + stats["transport_uptime"] = time.time()-RNS.Transport.start_time return stats diff --git a/RNS/Transport.py b/RNS/Transport.py index b105452..63e5436 100755 --- a/RNS/Transport.py +++ b/RNS/Transport.py @@ -115,9 +115,10 @@ class Transport: pending_local_path_requests = {} - jobs_locked = False - jobs_running = False - job_interval = 0.250 + start_time = None + jobs_locked = False + jobs_running = False + job_interval = 0.250 links_last_checked = 0.0 links_check_interval = 1.0 receipts_last_checked = 0.0 @@ -270,6 +271,7 @@ class Transport: RNS.log("Could not load tunnel table from storage, the contained exception was: "+str(e), RNS.LOG_ERROR) RNS.log("Transport instance "+str(Transport.identity)+" started", RNS.LOG_VERBOSE) + Transport.start_time = time.time() # Synthesize tunnels for any interfaces wanting it for interface in Transport.interfaces: diff --git a/RNS/Utilities/rnstatus.py b/RNS/Utilities/rnstatus.py index 67e74eb..93f737f 100644 --- a/RNS/Utilities/rnstatus.py +++ b/RNS/Utilities/rnstatus.py @@ -176,7 +176,7 @@ def program_setup(configdir, dispall=False, verbosity=0, name_filter=None,json=F 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 Reticulum Transport Instance "+RNS.prettyhexrep(stats["transport_id"])+" is running") + print("\n Reticulum Transport Instance "+RNS.prettyhexrep(stats["transport_id"])+" running, uptime is "+RNS.prettytime(stats["transport_uptime"])) print("")