mirror of
https://github.com/liamcottle/reticulum-meshchat.git
synced 2026-04-27 16:10:32 +00:00
allow meshchat to run a local propagation node
This commit is contained in:
parent
1b4d8cf794
commit
a47f33b985
3 changed files with 51 additions and 0 deletions
31
meshchat.py
31
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:
|
||||
|
|
|
|||
|
|
@ -93,6 +93,10 @@
|
|||
<div>LXMF Address</div>
|
||||
<div class="text-sm text-gray-700">{{ config.lxmf_address_hash }}</div>
|
||||
</div>
|
||||
<div class="p-1">
|
||||
<div>LXMF Propagation Node Address</div>
|
||||
<div class="text-sm text-gray-700">{{ config.lxmf_local_propagation_node_address_hash }}</div>
|
||||
</div>
|
||||
<div class="p-1">
|
||||
<div>Audio Call Address</div>
|
||||
<div class="text-sm text-gray-700">{{ config.audio_call_address_hash }}</div>
|
||||
|
|
|
|||
|
|
@ -82,6 +82,16 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="p-2">
|
||||
<div class="flex items-start">
|
||||
<div class="flex items-center h-5">
|
||||
<input v-model="config.lxmf_local_propagation_node_enabled" @change="onLxmfLocalPropagationNodeEnabledChange" type="checkbox" class="w-4 h-4 border border-gray-300 rounded bg-gray-50 focus:ring-3 focus:ring-blue-300">
|
||||
</div>
|
||||
<label class="ml-2 text-sm font-medium text-gray-900">Local Propagation Node</label>
|
||||
</div>
|
||||
<div class="text-sm text-gray-700">When enabled, MeshChat will run a Propagation Node and announce it for other clients to use.</div>
|
||||
</div>
|
||||
|
||||
<div class="p-2">
|
||||
<div class="text-sm font-medium text-gray-900">Preferred Propagation Node</div>
|
||||
<div class="flex">
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue