RRC: configurable max accepted resource transfer size

This commit is contained in:
Jeremy O'Brien
2026-07-12 20:30:15 -04:00
parent f07a03548b
commit 510d476c0d
2 changed files with 21 additions and 1 deletions
+15
View File
@@ -155,6 +155,7 @@ class NomadNetworkApp:
self.rrc_history_per_room_cap = 500
self.rrc_filter_loaded_history = True
self.rrc_max_accepted_resource_size = 256*1024
self.rrc_ephemeral_notices = 600
self.rrc_nick_colors = True
self.rrc_nick_colors_theme = None
@@ -994,6 +995,12 @@ class NomadNetworkApp:
except Exception: value = True
self.rrc_filter_loaded_history = value
if option == "max_accepted_resource_size":
try: value = self.config["rrc"].as_int(option)
except Exception: value = None
if value is not None and value >= 0:
self.rrc_max_accepted_resource_size = value*1024
if option == "ephemeral_notices":
try: value = self.config["rrc"].as_float(option)
except Exception: value = 0
@@ -1397,6 +1404,14 @@ history_per_room_cap = 500
# loaded.
filter_loaded_history = yes
# Maximum size in kilobytes of a resource
# transfer that will be accepted from a
# hub. Lower this on low-bandwidth links
# to automatically reject transfers that
# would take too long to receive. Set to
# 0 to reject all resource transfers.
max_accepted_resource_size = 256
# You can choose whether notices and sys
# messages persist indefinitely, or are
# removed from the message history after
+6 -1
View File
@@ -1213,7 +1213,12 @@ class RRCHub:
size = getattr(resource, "size", 0)
except Exception:
return False
if size > 262144:
try:
max_size = int(getattr(self.manager.app, "rrc_max_accepted_resource_size", 262144))
except Exception:
max_size = 262144
if max_size <= 0 or size > max_size:
self._log("rejecting resource transfer of "+str(size)+" bytes (max accepted is "+str(max_size)+" bytes)", RNS.LOG_DEBUG)
return False
return True