Added stack info to rnstatus discovered interfaces output

This commit is contained in:
Mark Qvist 2026-09-28 18:34:14 +02:00
parent 69c425d9ae
commit d3153bd778
No known key found for this signature in database
2 changed files with 16 additions and 4 deletions

View file

@ -345,6 +345,8 @@ class InterfaceAnnounceHandler:
if INTERFACE_TYPE in unpacked:
interface_type = unpacked[INTERFACE_TYPE]
name = self.sanitize_name(unpacked[NAME])
impl_name = unpacked[TRANSPORT_IMPL] if TRANSPORT_IMPL in unpacked else None
impl_version = unpacked[TRANSPORT_VERS] if TRANSPORT_VERS in unpacked else None
if type(unpacked[TRANSPORT]) != bool: raise ValueError("Invalid data in transport field of announce")
if type(unpacked[LATITUDE]) not in [type(None), float]: raise ValueError("Invalid data in latitude field of announce")
@ -359,6 +361,8 @@ class InterfaceAnnounceHandler:
raise ValueError("Invalid data in reachable_on field of announce")
info = {"type": interface_type,
"impl_name": impl_name,
"version": impl_version,
"transport": unpacked[TRANSPORT],
"name": name or f"Discovered {interface_type}",
"received": time.time(),
@ -574,11 +578,13 @@ class InterfaceDiscovery():
interface_type = info["type"]
discovery_hash = info["discovery_hash"]
discovered_type = info["type"]
has_impl_info = "impl_name" in info and "version" in info and info["impl_name"] and info["version"]
version_str = f" ({info['impl_name']} {info['version']})" if has_impl_info else " (unknown implementation)"
if not discovered_type in self.DISCOVERABLE_TYPES: return
hops = info["hops"]; ms = "" if hops == 1 else "s"
filename = RNS.hexrep(discovery_hash, delimit=False)
filepath = os.path.join(self.storagepath, filename)
RNS.log(f"Discovered {interface_type} {hops} hop{ms} away with stamp value {value}: {name}", RNS.LOG_DEBUG)
RNS.log(f"Discovered {interface_type}{version_str} {hops} hop{ms} away with stamp value {value}: {name}", RNS.LOG_DEBUG)
with self.discovery_lock:
if not os.path.isfile(filepath):
try:

View file

@ -243,6 +243,8 @@ def program_setup(configdir, dispall=False, verbosity=0, name_filter=None, json=
name = i["name"]
if_type = i["type"]
status = i["status"]
has_impl_info = "impl_name" in i and "version" in i and i["impl_name"] and i["version"]
impl_str = f"{i['impl_name']} {i['version']}" if has_impl_info else "Unknown"
if status == "available": status_display = "Available"
elif status == "unknown": status_display = "Unknown"
@ -279,6 +281,7 @@ def program_setup(configdir, dispall=False, verbosity=0, name_filter=None, json=
print(f"Name : {name}")
print(f"Type : {if_type}")
print(f"Stack : {impl_str}")
print(f"Status : {status_display}")
print(f"Transport : {transport_str}")
print(f"Distance : {i['hops']} hop{'' if i['hops'] == 1 else 's'}")
@ -303,12 +306,15 @@ def program_setup(configdir, dispall=False, verbosity=0, name_filter=None, json=
except Exception as e: pass
else:
print(f"{'Name':<25} {'Type':<12} {'Status':<12} {'Last Heard':<12} {'Value':<8} {'Location':<15}")
print("-" * 89)
print(f"{'Name':<25} {'Type':<10} {'Status':<10} {'Last Heard':<12} {'Value':<7} {'Running':<16} {'Location':<15}")
print("-" * 110)
for i in filtered_ifs:
try:
name = i["name"][:24] + "…" if len(i["name"]) > 24 else i["name"]
has_impl_info = "impl_name" in i and "version" in i and i["impl_name"] and i["version"]
impl_str = f"{i['impl_name']} {i['version']}" if has_impl_info else "Unknown"
if len(impl_str) > 16: impl_str = impl_str[:15]+"…"
if_type = i["type"].replace("Interface", "")
@ -341,7 +347,7 @@ def program_setup(configdir, dispall=False, verbosity=0, name_filter=None, json=
location = f"{lat}, {lon}"
else: location = "N/A"
print(f"{name:<25} {if_type:<12} {status_display:<12} {last_heard_display:<12} {value:<8} {location:<15}")
print(f"{name:<25} {if_type:<10} {status_display:<12} {last_heard_display:<12} {value:<7} {impl_str:<16} {location:<15}")
except Exception as e:
pass