Skip to content

Commit

Permalink
Added LXMF transfer size limit options
Browse files Browse the repository at this point in the history
  • Loading branch information
markqvist committed Mar 1, 2024
1 parent 4a3c987 commit d9bba6f
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 2 deletions.
46 changes: 44 additions & 2 deletions nomadnet/NomadNetworkApp.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,17 @@ def __init__(self, configdir = None, rnsconfigdir = None, daemon = False, force_
self.should_run_jobs = True
self.job_interval = 5
self.defer_jobs = 90
self.page_refresh_interval = 0
self.page_refresh_interval = 0
self.file_refresh_interval = 0

self.peer_announce_at_start = True
self.try_propagation_on_fail = True
self.disable_propagation = False
self.notify_on_new_message = True

self.lxmf_max_propagation_size = None
self.lxmf_max_incoming_size = None

self.periodic_lxmf_sync = True
self.lxmf_sync_interval = 360*60
self.lxmf_sync_limit = 8
Expand Down Expand Up @@ -283,7 +286,11 @@ def __init__(self, configdir = None, rnsconfigdir = None, daemon = False, force_

self.directory = nomadnet.Directory(self)

self.message_router = LXMF.LXMRouter(identity = self.identity, storagepath = self.storagepath, autopeer = True)
self.message_router = LXMF.LXMRouter(
identity = self.identity, storagepath = self.storagepath, autopeer = True,
propagation_limit = self.lxmf_max_propagation_size, delivery_limit = self.lxmf_max_incoming_size,
)

self.message_router.register_delivery_callback(self.lxmf_delivery)

for destination_hash in self.ignored_list:
Expand Down Expand Up @@ -731,6 +738,14 @@ def applyConfig(self):
else:
self.lxmf_sync_limit = None

if option == "max_accepted_size":
value = self.config["client"].as_float(option)

if value > 0:
self.lxmf_max_incoming_size = value
else:
self.lxmf_max_incoming_size = 500

if option == "compact_announce_stream":
value = self.config["client"].as_bool(option)
self.compact_stream = value
Expand Down Expand Up @@ -829,6 +844,14 @@ def applyConfig(self):
else:
self.disable_propagation = self.config["node"].as_bool("disable_propagation")

if not "max_transfer_size" in self.config["node"]:
self.lxmf_max_propagation_size = 256
else:
value = self.config["node"].as_float("max_transfer_size")
if value < 1:
value = 1
self.lxmf_max_propagation_size = value

if not "announce_at_start" in self.config["node"]:
self.node_announce_at_start = False
else:
Expand Down Expand Up @@ -994,6 +1017,13 @@ def quit(self):
# the limit, and download everything every time.
lxmf_sync_limit = 8
# The maximum accepted unpacked size for mes-
# sages received directly from other peers,
# specified in kilobytes. Messages larger than
# this will be rejected before the transfer
# begins.
max_accepted_size = 500
# The announce stream will only show one entry
# per destination or node by default. You can
# change this to show as many announces as have
Expand Down Expand Up @@ -1082,6 +1112,18 @@ def quit(self):
# and defaults to 2 gigabytes.
# message_storage_limit = 2000
# The maximum accepted transfer size per in-
# coming propagation transfer, in kilobytes.
# This also sets the upper limit for the size
# of single messages accepted onto this node.
#
# If a node wants to propagate a larger number
# of messages to this node, than what can fit
# within this limit, it will prioritise sending
# the smallest, newest messages first, and try
# with any remaining messages at a later point.
max_transfer_size = 256
# You can tell the LXMF message router to
# prioritise storage for one or more
# destinations. If the message store reaches
Expand Down
12 changes: 12 additions & 0 deletions nomadnet/ui/textui/Guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,12 @@ def focus_reader(self):
On low-bandwidth networks, it can be useful to limit the amount of messages downloaded in each sync. The default is 8. Set to 0 to download all available messages every time a sync occurs.
<
>>>
`!max_accepted_size = 500`!
>>>>
The maximum accepted unpacked size for messages received directly from other peers, specified in kilobytes. Messages larger than this will be rejected before the transfer begins.
<
>>>
`!compact_announce_stream = yes`!
>>>>
Expand Down Expand Up @@ -653,6 +659,12 @@ def focus_reader(self):
Configures the maximum amount of storage, in megabytes, that the LXMF Propagation Node will use to store messages.
<
>>>
`!max_transfer_size = 256`!
>>>>
The maximum accepted transfer size per incoming propagation transfer, in kilobytes. This also sets the upper limit for the size of single messages accepted onto this propagation node. If a node wants to propagate a larger number of messages to this node, than what can fit within this limit, it will prioritise sending the smallest, newest messages first, and try with any remaining messages at a later point.
<
>>>
`!prioritise_destinations = 41d20c727598a3fbbdf9106133a3a0ed, d924b81822ca24e68e2effea99bcb8cf`!
>>>>
Expand Down

0 comments on commit d9bba6f

Please sign in to comment.