Added peering settings to lxmd

This commit is contained in:
Mark Qvist 2022-10-22 21:25:15 +02:00
parent 1c4928a29b
commit 2d81b47b6a
2 changed files with 22 additions and 2 deletions

View File

@ -976,7 +976,8 @@ class LXMRouter:
remote_hash = remote_destination.hash remote_hash = remote_destination.hash
if not remote_hash in self.peers: if not remote_hash in self.peers:
self.peer(remote_hash, remote_timebase) if self.autopeer and RNS.Transport.hops_to(remote_hash) <= self.autopeer_maxdepth:
self.peer(remote_hash, remote_timebase)
messages = data[1] messages = data[1]
for lxmf_data in messages: for lxmf_data in messages:

View File

@ -94,6 +94,16 @@ def apply_config():
else: else:
active_configuration["node_announce_at_start"] = False active_configuration["node_announce_at_start"] = False
if "propagation" in lxmd_config and "autopeer" in lxmd_config["propagation"]:
active_configuration["autopeer"] = lxmd_config["propagation"].as_bool("autopeer")
else:
active_configuration["autopeer"] = True
if "propagation" in lxmd_config and "autopeer_maxdepth" in lxmd_config["propagation"]:
active_configuration["autopeer_maxdepth"] = lxmd_config["propagation"].as_int("autopeer_maxdepth")
else:
active_configuration["autopeer_maxdepth"] = None
if "propagation" in lxmd_config and "announce_interval" in lxmd_config["propagation"]: if "propagation" in lxmd_config and "announce_interval" in lxmd_config["propagation"]:
active_configuration["node_announce_interval"] = lxmd_config["propagation"].as_int("announce_interval")*60 active_configuration["node_announce_interval"] = lxmd_config["propagation"].as_int("announce_interval")*60
else: else:
@ -241,7 +251,12 @@ def program_setup(configdir = None, rnsconfigdir = None, run_pn = False, on_inbo
exit(2) exit(2)
# Start LXMF # Start LXMF
message_router = LXMF.LXMRouter(identity = identity, storagepath = storagedir, autopeer = True) message_router = LXMF.LXMRouter(
identity = identity,
storagepath = storagedir,
autopeer = active_configuration["autopeer"],
autopeer_maxdepth = active_configuration["autopeer_maxdepth"],
)
message_router.register_delivery_callback(lxmf_delivery) message_router.register_delivery_callback(lxmf_delivery)
for destination_hash in active_configuration["ignored_lxmf_destinations"]: for destination_hash in active_configuration["ignored_lxmf_destinations"]:
@ -371,6 +386,10 @@ announce_at_start = yes
# propagation nodes on the network. # propagation nodes on the network.
autopeer = yes autopeer = yes
# The maximum peering depth (in hops) for
# automatically peered nodes.
autopeer_maxdepth = 4
# The maximum amount of storage to use for # The maximum amount of storage to use for
# the LXMF Propagation Node message store, # the LXMF Propagation Node message store,
# specified in megabytes. When this limit # specified in megabytes. When this limit