diff --git a/meshchat.py b/meshchat.py index 699e839..a19c00a 100644 --- a/meshchat.py +++ b/meshchat.py @@ -123,6 +123,10 @@ class ReticulumMeshChat: # update active propagation node self.set_active_propagation_node(self.config.lxmf_preferred_propagation_node_destination_hash.get()) + # enable propagation node (we don't call with false if disabled, as no need to announce disabled state every launch) + if self.config.lxmf_local_propagation_node_enabled.get(): + self.enable_local_propagation_node() + # handle received announces based on aspect RNS.Transport.register_announce_handler(AnnounceHandler("call.audio", self.on_audio_call_announce_received)) RNS.Transport.register_announce_handler(AnnounceHandler("lxmf.delivery", self.on_lxmf_announce_received)) @@ -244,6 +248,17 @@ class ReticulumMeshChat: self.stop_propagation_node_sync() self.message_router.outbound_propagation_node = None + # enables or disables the local lxmf propagation node + def enable_local_propagation_node(self, enabled: bool = True): + try: + if enabled: + self.message_router.enable_propagation() + else: + self.message_router.disable_propagation() + except: + print("failed to enable or disable propagation node") + pass + # handle receiving a new audio call def on_incoming_audio_call(self, audio_call: AudioCall): print("on_incoming_audio_call: {}".format(audio_call.link.hash.hex())) @@ -1301,6 +1316,10 @@ class ReticulumMeshChat: self.local_lxmf_destination.display_name = self.config.display_name.get() self.message_router.announce(destination_hash=self.local_lxmf_destination.hash) + # send announce for local propagation node (if enabled) + if self.config.lxmf_local_propagation_node_enabled.get(): + self.message_router.announce_propagation_node() + # send announce for audio call self.audio_call_manager.announce(app_data=self.config.display_name.get().encode("utf-8")) @@ -1368,6 +1387,15 @@ class ReticulumMeshChat: value = int(data["lxmf_preferred_propagation_node_auto_sync_interval_seconds"]) self.config.lxmf_preferred_propagation_node_auto_sync_interval_seconds.set(value) + if "lxmf_local_propagation_node_enabled" in data: + + # update config value + value = bool(data["lxmf_local_propagation_node_enabled"]) + self.config.lxmf_local_propagation_node_enabled.set(value) + + # enable or disable local propagation node + self.enable_local_propagation_node(value) + # send config to websocket clients await self.send_config_to_websocket_clients() @@ -1531,6 +1559,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_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(), "lxmf_preferred_propagation_node_auto_sync_interval_seconds": self.config.lxmf_preferred_propagation_node_auto_sync_interval_seconds.get(), "lxmf_preferred_propagation_node_last_synced_at": self.config.lxmf_preferred_propagation_node_last_synced_at.get(), @@ -2353,6 +2383,7 @@ class Config: 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) + lxmf_local_propagation_node_enabled = BoolConfig("lxmf_local_propagation_node_enabled", False) class NomadnetDownloader: diff --git a/src/frontend/components/about/AboutPage.vue b/src/frontend/components/about/AboutPage.vue index 01e9590..c92bdd6 100644 --- a/src/frontend/components/about/AboutPage.vue +++ b/src/frontend/components/about/AboutPage.vue @@ -93,6 +93,10 @@
LXMF Address
{{ config.lxmf_address_hash }}
+
+
LXMF Propagation Node Address
+
{{ config.lxmf_local_propagation_node_address_hash }}
+
Audio Call Address
{{ config.audio_call_address_hash }}
diff --git a/src/frontend/components/settings/SettingsPage.vue b/src/frontend/components/settings/SettingsPage.vue index 47d4271..c0e37aa 100644 --- a/src/frontend/components/settings/SettingsPage.vue +++ b/src/frontend/components/settings/SettingsPage.vue @@ -82,6 +82,16 @@
+
+
+
+ +
+ +
+
When enabled, MeshChat will run a Propagation Node and announce it for other clients to use.
+
+
Preferred Propagation Node
@@ -130,6 +140,7 @@ export default { allow_auto_resending_failed_messages_with_attachments: null, auto_send_failed_messages_to_propagation_node: null, show_suggested_community_interfaces: null, + lxmf_local_propagation_node_enabled: null, lxmf_preferred_propagation_node_destination_hash: null, }, }; @@ -201,6 +212,11 @@ export default { "lxmf_preferred_propagation_node_destination_hash": this.config.lxmf_preferred_propagation_node_destination_hash, }); }, + async onLxmfLocalPropagationNodeEnabledChange() { + await this.updateConfig({ + "lxmf_local_propagation_node_enabled": this.config.lxmf_local_propagation_node_enabled, + }); + }, async onLxmfPreferredPropagationNodeAutoSyncIntervalSecondsChange() { await this.updateConfig({ "lxmf_preferred_propagation_node_auto_sync_interval_seconds": this.config.lxmf_preferred_propagation_node_auto_sync_interval_seconds,