mirror of
https://github.com/markqvist/Reticulum.git
synced 2025-05-02 06:36:14 -04:00
Added max hops filter to rnpath table output
This commit is contained in:
parent
219d717afb
commit
cf87b1352a
2 changed files with 28 additions and 14 deletions
|
@ -1194,7 +1194,8 @@ class Reticulum:
|
|||
rpc_connection.send(self.get_interface_stats())
|
||||
|
||||
if path == "path_table":
|
||||
rpc_connection.send(self.get_path_table())
|
||||
mh = call["max_hops"]
|
||||
rpc_connection.send(self.get_path_table(max_hops=mh))
|
||||
|
||||
if path == "rate_table":
|
||||
rpc_connection.send(self.get_rate_table())
|
||||
|
@ -1340,25 +1341,27 @@ class Reticulum:
|
|||
|
||||
return stats
|
||||
|
||||
def get_path_table(self):
|
||||
def get_path_table(self, max_hops=None):
|
||||
if self.is_connected_to_shared_instance:
|
||||
rpc_connection = multiprocessing.connection.Client(self.rpc_addr, authkey=self.rpc_key)
|
||||
rpc_connection.send({"get": "path_table"})
|
||||
rpc_connection.send({"get": "path_table", "max_hops": max_hops})
|
||||
response = rpc_connection.recv()
|
||||
return response
|
||||
|
||||
else:
|
||||
path_table = []
|
||||
for dst_hash in RNS.Transport.destination_table:
|
||||
entry = {
|
||||
"hash": dst_hash,
|
||||
"timestamp": RNS.Transport.destination_table[dst_hash][0],
|
||||
"via": RNS.Transport.destination_table[dst_hash][1],
|
||||
"hops": RNS.Transport.destination_table[dst_hash][2],
|
||||
"expires": RNS.Transport.destination_table[dst_hash][3],
|
||||
"interface": str(RNS.Transport.destination_table[dst_hash][5]),
|
||||
}
|
||||
path_table.append(entry)
|
||||
path_hops = RNS.Transport.destination_table[dst_hash][2]
|
||||
if max_hops == None or path_hops <= max_hops:
|
||||
entry = {
|
||||
"hash": dst_hash,
|
||||
"timestamp": RNS.Transport.destination_table[dst_hash][0],
|
||||
"via": RNS.Transport.destination_table[dst_hash][1],
|
||||
"hops": path_hops,
|
||||
"expires": RNS.Transport.destination_table[dst_hash][3],
|
||||
"interface": str(RNS.Transport.destination_table[dst_hash][5]),
|
||||
}
|
||||
path_table.append(entry)
|
||||
|
||||
return path_table
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue