add setting to enable and disable transport mode
This commit is contained in:
25
meshchat.py
25
meshchat.py
@@ -779,6 +779,30 @@ class ReticulumMeshChat:
|
||||
"config": self.get_config_dict(),
|
||||
})
|
||||
|
||||
# enable transport mode
|
||||
@routes.post("/api/v1/reticulum/enable-transport")
|
||||
async def index(request):
|
||||
|
||||
# enable transport mode
|
||||
self.reticulum.config["reticulum"]["enable_transport"] = True
|
||||
self.reticulum.config.write()
|
||||
|
||||
return web.json_response({
|
||||
"message": "Transport has been enabled. MeshChat must be restarted for this change to take effect.",
|
||||
})
|
||||
|
||||
# disable transport mode
|
||||
@routes.post("/api/v1/reticulum/disable-transport")
|
||||
async def index(request):
|
||||
|
||||
# disable transport mode
|
||||
self.reticulum.config["reticulum"]["enable_transport"] = False
|
||||
self.reticulum.config.write()
|
||||
|
||||
return web.json_response({
|
||||
"message": "Transport has been disabled. MeshChat must be restarted for this change to take effect.",
|
||||
})
|
||||
|
||||
# get calls
|
||||
@routes.get("/api/v1/calls")
|
||||
async def index(request):
|
||||
@@ -2006,6 +2030,7 @@ class ReticulumMeshChat:
|
||||
"identity_hash": self.identity.hexhash,
|
||||
"lxmf_address_hash": self.local_lxmf_destination.hexhash,
|
||||
"audio_call_address_hash": self.audio_call_manager.audio_call_receiver.destination.hexhash,
|
||||
"is_transport_enabled": self.reticulum.transport_enabled(),
|
||||
"auto_announce_enabled": self.config.auto_announce_enabled.get(),
|
||||
"auto_announce_interval_seconds": self.config.auto_announce_interval_seconds.get(),
|
||||
"last_announced_at": self.config.last_announced_at.get(),
|
||||
|
||||
@@ -37,6 +37,25 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- transport mode -->
|
||||
<div class="bg-white dark:bg-zinc-800 rounded shadow">
|
||||
<div class="flex border-b border-gray-300 dark:border-zinc-700 text-gray-700 dark:text-gray-200 p-2 font-semibold">Transport Mode</div>
|
||||
<div class="divide-y divide-gray-300 dark:divide-zinc-700 text-gray-900 dark:text-gray-100">
|
||||
|
||||
<div class="p-2">
|
||||
<div class="flex items-start">
|
||||
<div class="flex items-center h-5">
|
||||
<input v-model="config.is_transport_enabled" @change="onIsTransportEnabledChange" type="checkbox" class="w-4 h-4 border border-gray-300 dark:border-zinc-600 rounded bg-gray-50 dark:bg-zinc-700 focus:ring-3 focus:ring-blue-300 dark:focus:ring-blue-600">
|
||||
</div>
|
||||
<label class="ml-2 text-sm font-medium text-gray-900 dark:text-gray-100">Enable Transport Mode</label>
|
||||
</div>
|
||||
<div class="text-sm text-gray-700 dark:text-gray-300">When enabled, MeshChat will route traffic for other peers, respond to path requests and pass announces over your interfaces.</div>
|
||||
<div class="text-sm text-gray-700 dark:text-gray-300">Changing this setting requires you to restart MeshChat.</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- messages -->
|
||||
<div class="bg-white dark:bg-zinc-800 rounded shadow">
|
||||
<div class="flex border-b border-gray-300 dark:border-zinc-700 text-gray-700 dark:text-gray-200 p-2 font-semibold">Messages</div>
|
||||
@@ -150,6 +169,7 @@
|
||||
<script>
|
||||
import Utils from "../../js/Utils";
|
||||
import WebSocketConnection from "../../js/WebSocketConnection";
|
||||
import DialogUtils from "../../js/DialogUtils";
|
||||
|
||||
export default {
|
||||
name: 'SettingsPage',
|
||||
@@ -247,6 +267,25 @@ export default {
|
||||
"lxmf_preferred_propagation_node_auto_sync_interval_seconds": this.config.lxmf_preferred_propagation_node_auto_sync_interval_seconds,
|
||||
});
|
||||
},
|
||||
async onIsTransportEnabledChange() {
|
||||
if(this.config.is_transport_enabled){
|
||||
try {
|
||||
const response = await window.axios.post("/api/v1/reticulum/enable-transport");
|
||||
DialogUtils.alert(response.data.message);
|
||||
} catch(e) {
|
||||
DialogUtils.alert("Failed to enable transport mode!");
|
||||
console.log(e);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
const response = await window.axios.post("/api/v1/reticulum/disable-transport");
|
||||
DialogUtils.alert(response.data.message);
|
||||
} catch(e) {
|
||||
DialogUtils.alert("Failed to disable transport mode!");
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
},
|
||||
formatSecondsAgo: function(seconds) {
|
||||
return Utils.formatSecondsAgo(seconds);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user