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(() => {