From 18c2568c22c2e4ddb7c6b30563487fa26a12961c Mon Sep 17 00:00:00 2001 From: Tom Mills Date: Mon, 20 Apr 2026 09:00:35 +0100 Subject: [PATCH] Add preshared key default toggle (#1207) * Add previous PR changes * Import lowercase dayjs * Build dist * Revert "Build dist" This reverts commit 152da2ca1030f559f3903c036605cd5fa95e6a03 Dist not to be built at @DaanSelen request --- src/modules/DashboardConfig.py | 3 ++- .../newPeersComponents/presharedKeyInput.vue | 19 ++++++++++++++----- .../configurationComponents/peerAddModal.vue | 6 +++--- .../configurationComponents/peerCreate.vue | 6 +++--- .../settingsComponent/peerDefaultSettings.vue | 4 +++- .../peersDefaultSettingsInput.vue | 16 ++++++++++++++-- 6 files changed, 39 insertions(+), 15 deletions(-) diff --git a/src/modules/DashboardConfig.py b/src/modules/DashboardConfig.py index 958c39b3..b1a63499 100644 --- a/src/modules/DashboardConfig.py +++ b/src/modules/DashboardConfig.py @@ -51,7 +51,8 @@ class DashboardConfig: "peer_display_mode": "grid", "remote_endpoint": GetRemoteEndpoint(), "peer_MTU": "1420", - "peer_keep_alive": "21" + "peer_keep_alive": "21", + "peer_preshared_key_default": "false" }, "Other": { "welcome_session": "true" diff --git a/src/static/app/src/components/configurationComponents/newPeersComponents/presharedKeyInput.vue b/src/static/app/src/components/configurationComponents/newPeersComponents/presharedKeyInput.vue index 2918e373..d7f2ba4c 100644 --- a/src/static/app/src/components/configurationComponents/newPeersComponents/presharedKeyInput.vue +++ b/src/static/app/src/components/configurationComponents/newPeersComponents/presharedKeyInput.vue @@ -6,18 +6,27 @@ export default { components: {LocaleText}, props: { data: Object, - saving: Boolean + saving: Boolean, + defaultEnabled: Boolean }, data(){ return{ enable: false } }, + mounted() { + const hasKey = !!(this.data && this.data.preshared_key && this.data.preshared_key.length > 0) + if (hasKey || this.defaultEnabled){ + this.enable = true + } + }, watch:{ enable(){ - if (this.enable){ - this.data.preshared_key = window.wireguard.generateKeypair().presharedKey - }else { + if (this.enable) { + if (!this.data.preshared_key){ + this.data.preshared_key = window.wireguard.generateKeypair().presharedKey + } + } else { this.data.preshared_key = "" } } @@ -48,4 +57,4 @@ export default { \ No newline at end of file + diff --git a/src/static/app/src/components/configurationComponents/peerAddModal.vue b/src/static/app/src/components/configurationComponents/peerAddModal.vue index e0ccded2..25f8b238 100644 --- a/src/static/app/src/components/configurationComponents/peerAddModal.vue +++ b/src/static/app/src/components/configurationComponents/peerAddModal.vue @@ -32,7 +32,7 @@ const peerData = ref({ keepalive: parseInt(dashboardStore.Configuration.Peers.peer_keep_alive), mtu: parseInt(dashboardStore.Configuration.Peers.peer_mtu), preshared_key: "", - preshared_key_bulkAdd: false, + preshared_key_bulkAdd: Boolean(dashboardStore.Configuration.Peers.peer_preshared_key_default), allowed_ips_validation: true, }) const availableIp = ref([]) @@ -128,7 +128,7 @@ watch(() => {
- +
@@ -177,4 +177,4 @@ watch(() => { \ No newline at end of file + diff --git a/src/static/app/src/components/configurationComponents/peerCreate.vue b/src/static/app/src/components/configurationComponents/peerCreate.vue index c1c9aedf..d0108585 100644 --- a/src/static/app/src/components/configurationComponents/peerCreate.vue +++ b/src/static/app/src/components/configurationComponents/peerCreate.vue @@ -36,7 +36,7 @@ export default { keepalive: parseInt(this.dashboardStore.Configuration.Peers.peer_keep_alive), mtu: parseInt(this.dashboardStore.Configuration.Peers.peer_mtu), preshared_key: "", - preshared_key_bulkAdd: false, + preshared_key_bulkAdd: Boolean(this.dashboardStore.Configuration.Peers.peer_preshared_key_default), }, availableIp: undefined, availableIpSearchString: "", @@ -133,7 +133,7 @@ export default {
- +
@@ -187,4 +187,4 @@ div{ .card{ max-height: 100%; } - \ No newline at end of file + diff --git a/src/static/app/src/components/settingsComponent/peerDefaultSettings.vue b/src/static/app/src/components/settingsComponent/peerDefaultSettings.vue index eeccaf8b..be9c30b7 100644 --- a/src/static/app/src/components/settingsComponent/peerDefaultSettings.vue +++ b/src/static/app/src/components/settingsComponent/peerDefaultSettings.vue @@ -22,6 +22,8 @@ import PeersDefaultSettingsInput from "@/components/settingsComponent/peersDefau targetData="peer_mtu" title="MTU"> + - \ No newline at end of file + diff --git a/src/static/app/src/components/settingsComponent/peersDefaultSettingsInput.vue b/src/static/app/src/components/settingsComponent/peersDefaultSettingsInput.vue index 0b6b97c3..2ffac249 100644 --- a/src/static/app/src/components/settingsComponent/peersDefaultSettingsInput.vue +++ b/src/static/app/src/components/settingsComponent/peersDefaultSettingsInput.vue @@ -31,6 +31,11 @@ export default { mounted() { this.value = this.store.Configuration.Peers[this.targetData]; }, + computed: { + isBoolean(){ + return typeof this.value === "boolean" + } + }, methods:{ async useValidation(){ if(this.changed){ @@ -67,7 +72,14 @@ export default { - + +
+ - \ No newline at end of file +