diff --git a/meshchat.py b/meshchat.py index d574dda..7a741f2 100644 --- a/meshchat.py +++ b/meshchat.py @@ -126,8 +126,13 @@ class ReticulumMeshChat: self.local_lxmf_destination = self.message_router.register_delivery_identity( identity=self.identity, display_name=self.config.display_name.get(), + stamp_cost=self.config.lxmf_inbound_stamp_cost.get(), ) + # drop inbound messages without a valid stamp if enforcement is enabled + if self.config.lxmf_enforce_inbound_stamp_cost.get(): + self.message_router.enforce_stamps() + # set a callback for when an lxmf message is received self.message_router.register_delivery_callback(self.on_lxmf_delivery) @@ -2133,6 +2138,20 @@ class ReticulumMeshChat: value = bool(data["show_suggested_community_interfaces"]) self.config.show_suggested_community_interfaces.set(value) + if "lxmf_inbound_stamp_cost" in data: + value = int(data["lxmf_inbound_stamp_cost"]) + if 0 <= value <= 254: + self.config.lxmf_inbound_stamp_cost.set(value) + self.message_router.set_inbound_stamp_cost(self.local_lxmf_destination.hash, value) + + if "lxmf_enforce_inbound_stamp_cost" in data: + value = bool(data["lxmf_enforce_inbound_stamp_cost"]) + self.config.lxmf_enforce_inbound_stamp_cost.set(value) + if value: + self.message_router.enforce_stamps() + else: + self.message_router.ignore_stamps() + if "lxmf_preferred_propagation_node_destination_hash" in data: # update config value @@ -2388,6 +2407,8 @@ class ReticulumMeshChat: "allow_auto_resending_failed_messages_with_attachments": self.config.allow_auto_resending_failed_messages_with_attachments.get(), "auto_send_failed_messages_to_propagation_node": self.config.auto_send_failed_messages_to_propagation_node.get(), "show_suggested_community_interfaces": self.config.show_suggested_community_interfaces.get(), + "lxmf_inbound_stamp_cost": self.config.lxmf_inbound_stamp_cost.get(), + "lxmf_enforce_inbound_stamp_cost": self.config.lxmf_enforce_inbound_stamp_cost.get(), "lxmf_local_propagation_node_enabled": self.config.lxmf_local_propagation_node_enabled.get(), "lxmf_local_propagation_node_address_hash": self.message_router.propagation_destination.hexhash, "lxmf_preferred_propagation_node_destination_hash": self.config.lxmf_preferred_propagation_node_destination_hash.get(), @@ -3410,6 +3431,8 @@ class Config: auto_send_failed_messages_to_propagation_node = BoolConfig("auto_send_failed_messages_to_propagation_node", False) show_suggested_community_interfaces = BoolConfig("show_suggested_community_interfaces", True) lxmf_delivery_transfer_limit_in_bytes = IntConfig("lxmf_delivery_transfer_limit_in_bytes", 1000 * 1000 * 10) # 10MB + lxmf_inbound_stamp_cost = IntConfig("lxmf_inbound_stamp_cost", 0) # 0 = disabled, valid range 1-254 + lxmf_enforce_inbound_stamp_cost = BoolConfig("lxmf_enforce_inbound_stamp_cost", False) lxmf_preferred_propagation_node_destination_hash = StringConfig("lxmf_preferred_propagation_node_destination_hash", None) lxmf_preferred_propagation_node_auto_sync_interval_seconds = IntConfig("lxmf_preferred_propagation_node_auto_sync_interval_seconds", 0) lxmf_preferred_propagation_node_last_synced_at = IntConfig("lxmf_preferred_propagation_node_last_synced_at", None) diff --git a/src/frontend/components/settings/SettingsPage.vue b/src/frontend/components/settings/SettingsPage.vue index 5b21634..4be8c85 100644 --- a/src/frontend/components/settings/SettingsPage.vue +++ b/src/frontend/components/settings/SettingsPage.vue @@ -91,6 +91,22 @@