mirror of
https://github.com/markqvist/Reticulum.git
synced 2026-11-19 14:36:34 -05:00
Added path state info to path table getters
This commit is contained in:
parent
1f7cd14513
commit
41260ea163
3 changed files with 12 additions and 2 deletions
|
|
@ -2043,7 +2043,8 @@ class Reticulum:
|
|||
"expires": RNS.Transport.path_table[dst_hash][3], "value": dst_value,
|
||||
"used": RNS.Transport.path_table[dst_hash][7], "lr_cost": lr_cost,
|
||||
"interface": str(RNS.Transport.path_table[dst_hash][5]),
|
||||
"interface_hash": RNS.Transport.path_table[dst_hash][5].get_hash() }
|
||||
"interface_hash": RNS.Transport.path_table[dst_hash][5].get_hash(),
|
||||
"state": RNS.Transport.get_path_state(dst_hash) }
|
||||
path_table.append(entry)
|
||||
|
||||
return path_table
|
||||
|
|
|
|||
|
|
@ -3863,6 +3863,10 @@ class Transport:
|
|||
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def get_path_state(destination_hash):
|
||||
return Transport.path_states.get(destination_hash, Transport.STATE_UNKNOWN)
|
||||
|
||||
@staticmethod
|
||||
def await_path(destination_hash, timeout=None, on_interface=None):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -300,6 +300,11 @@ def program_setup(configdir, table, rates, drop, destination_hexhash, verbosity,
|
|||
if not path["value"]: continue
|
||||
if path["value"] < min_value: continue
|
||||
|
||||
if path["state"] == RNS.Transport.STATE_RESPONSIVE: state_str = " (R)"
|
||||
elif path["state"] == RNS.Transport.STATE_UNRESPONSIVE: state_str = " (u)"
|
||||
elif path["state"] == RNS.Transport.STATE_UNKNOWN: state_str = " (?)"
|
||||
else: state_str = " (?)"
|
||||
|
||||
exp_str = RNS.timestamp_str(path["expires"])
|
||||
if path["hops"] == 1: m_str = " "
|
||||
else: m_str = "s"
|
||||
|
|
@ -310,7 +315,7 @@ def program_setup(configdir, table, rates, drop, destination_hexhash, verbosity,
|
|||
else: u_str = ""
|
||||
via_str = f" via {RNS.prettyhexrep(path['via'])}" if vias else ""
|
||||
exp_str = f" expires in {RNS.prettytime(path['expires']-now, compact=True)}" if expinfo else ""
|
||||
print(f"{RNS.prettyhexrep(path['hash'])} {path['hops']:>3}h{via_str} on {path['interface']}{exp_str} (dv:{RNS.prettycost(path['value'])}/lc:{RNS.prettycost(path['lr_cost'])}){u_str}")
|
||||
print(f"{RNS.prettyhexrep(path['hash'])} {path['hops']:>3}h{state_str}{via_str} on {path['interface']}{exp_str} (dv:{RNS.prettycost(path['value'])}/lc:{RNS.prettycost(path['lr_cost'])}){u_str}")
|
||||
|
||||
if destination_hash != None and displayed == 0:
|
||||
print("No path known")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue