Implemented getting static peer configuration from network if unknown at launch

This commit is contained in:
Mark Qvist 2025-10-31 17:11:17 +01:00
parent a44c1f368a
commit 606a723e31
2 changed files with 42 additions and 50 deletions

View file

@ -39,7 +39,6 @@ class LXMFPropagationAnnounceHandler:
self.lxmrouter = lxmrouter
def received_announce(self, destination_hash, announced_identity, app_data, announce_packet_hash, is_path_response):
if not is_path_response:
try:
if type(app_data) == bytes:
if self.lxmrouter.propagation_node:
@ -55,6 +54,8 @@ class LXMFPropagationAnnounceHandler:
metadata = data[6]
if destination_hash in self.lxmrouter.static_peers:
static_peer = self.lxmrouter.static_peers[destination_hash]
if not is_path_response or static_peer.last_heard == 0:
self.lxmrouter.peer(destination_hash=destination_hash,
timestamp=node_timebase,
propagation_transfer_limit=propagation_transfer_limit,
@ -65,7 +66,7 @@ class LXMFPropagationAnnounceHandler:
metadata=metadata)
else:
if self.lxmrouter.autopeer:
if self.lxmrouter.autopeer and not is_path_response:
if propagation_enabled == True:
if RNS.Transport.hops_to(destination_hash) <= self.lxmrouter.autopeer_maxdepth:
self.lxmrouter.peer(destination_hash=destination_hash,

View file

@ -540,9 +540,6 @@ class LXMRouter:
peer = LXMPeer.from_bytes(serialised_peer, self)
del serialised_peer
if peer.destination_hash in self.static_peers and peer.last_heard == 0:
# TODO: Allow path request responses through announce handler
# momentarily here, so peering config can be updated even if
# the static peer is not available to directly send an announce.
RNS.Transport.request_path(peer.destination_hash)
if peer.identity != None:
self.peers[peer.destination_hash] = peer
@ -2016,9 +2013,6 @@ class LXMRouter:
remote_timebase = data[0]
messages = data[1]
#######################################
# TODO: Check propagation stamps here #
#######################################
min_accepted_cost = max(0, self.propagation_stamp_cost-self.propagation_stamp_cost_flexibility)
validated_messages = LXStamper.validate_pn_stamps(messages, min_accepted_cost)
@ -2119,9 +2113,6 @@ class LXMRouter:
ms = "" if len(messages) == 1 else "s"
RNS.log(f"Received {len(messages)} message{ms} from {remote_str}", RNS.LOG_VERBOSE)
#######################################
# TODO: Check propagation stamps here #
#######################################
min_accepted_cost = max(0, self.propagation_stamp_cost-self.propagation_stamp_cost_flexibility)
validated_messages = LXStamper.validate_pn_stamps(messages, min_accepted_cost)