Add preshared key default toggle (#1207)
Some checks are pending
Docker Build and Push / docker_build (push) Waiting to run
Docker Build and Push / docker_scan (push) Blocked by required conditions

* Add previous PR changes

* Import lowercase dayjs

* Build dist

* Revert "Build dist"

This reverts commit 152da2ca10
Dist not to be built at @DaanSelen request
This commit is contained in:
Tom Mills
2026-04-20 09:00:35 +01:00
committed by GitHub
parent d58e082336
commit 18c2568c22
6 changed files with 39 additions and 15 deletions

View File

@@ -51,7 +51,8 @@ class DashboardConfig:
"peer_display_mode": "grid", "peer_display_mode": "grid",
"remote_endpoint": GetRemoteEndpoint(), "remote_endpoint": GetRemoteEndpoint(),
"peer_MTU": "1420", "peer_MTU": "1420",
"peer_keep_alive": "21" "peer_keep_alive": "21",
"peer_preshared_key_default": "false"
}, },
"Other": { "Other": {
"welcome_session": "true" "welcome_session": "true"

View File

@@ -6,17 +6,26 @@ export default {
components: {LocaleText}, components: {LocaleText},
props: { props: {
data: Object, data: Object,
saving: Boolean saving: Boolean,
defaultEnabled: Boolean
}, },
data(){ data(){
return{ return{
enable: false 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:{ watch:{
enable(){ enable(){
if (this.enable) { if (this.enable) {
if (!this.data.preshared_key){
this.data.preshared_key = window.wireguard.generateKeypair().presharedKey this.data.preshared_key = window.wireguard.generateKeypair().presharedKey
}
} else { } else {
this.data.preshared_key = "" this.data.preshared_key = ""
} }

View File

@@ -32,7 +32,7 @@ const peerData = ref({
keepalive: parseInt(dashboardStore.Configuration.Peers.peer_keep_alive), keepalive: parseInt(dashboardStore.Configuration.Peers.peer_keep_alive),
mtu: parseInt(dashboardStore.Configuration.Peers.peer_mtu), mtu: parseInt(dashboardStore.Configuration.Peers.peer_mtu),
preshared_key: "", preshared_key: "",
preshared_key_bulkAdd: false, preshared_key_bulkAdd: Boolean(dashboardStore.Configuration.Peers.peer_preshared_key_default),
allowed_ips_validation: true, allowed_ips_validation: true,
}) })
const availableIp = ref([]) const availableIp = ref([])
@@ -128,7 +128,7 @@ watch(() => {
<EndpointAllowedIps :saving="saving" :data="peerData"></EndpointAllowedIps> <EndpointAllowedIps :saving="saving" :data="peerData"></EndpointAllowedIps>
<div class="row gy-3"> <div class="row gy-3">
<div class="col-sm" v-if="!peerData.bulkAdd"> <div class="col-sm" v-if="!peerData.bulkAdd">
<PresharedKeyInput :saving="saving" :data="peerData" :bulk="peerData.bulkAdd"></PresharedKeyInput> <PresharedKeyInput :saving="saving" :data="peerData" :bulk="peerData.bulkAdd" :defaultEnabled="Boolean(dashboardStore.Configuration.Peers.peer_preshared_key_default)"></PresharedKeyInput>
</div> </div>
<div class="col-sm"> <div class="col-sm">

View File

@@ -36,7 +36,7 @@ export default {
keepalive: parseInt(this.dashboardStore.Configuration.Peers.peer_keep_alive), keepalive: parseInt(this.dashboardStore.Configuration.Peers.peer_keep_alive),
mtu: parseInt(this.dashboardStore.Configuration.Peers.peer_mtu), mtu: parseInt(this.dashboardStore.Configuration.Peers.peer_mtu),
preshared_key: "", preshared_key: "",
preshared_key_bulkAdd: false, preshared_key_bulkAdd: Boolean(this.dashboardStore.Configuration.Peers.peer_preshared_key_default),
}, },
availableIp: undefined, availableIp: undefined,
availableIpSearchString: "", availableIpSearchString: "",
@@ -133,7 +133,7 @@ export default {
<hr class="mb-0 mt-2"> <hr class="mb-0 mt-2">
<div class="row gy-3"> <div class="row gy-3">
<div class="col-sm" v-if="!this.data.bulkAdd"> <div class="col-sm" v-if="!this.data.bulkAdd">
<PresharedKeyInput :saving="saving" :data="data" :bulk="this.data.bulkAdd"></PresharedKeyInput> <PresharedKeyInput :saving="saving" :data="data" :bulk="this.data.bulkAdd" :defaultEnabled="Boolean(this.dashboardStore.Configuration.Peers.peer_preshared_key_default)"></PresharedKeyInput>
</div> </div>
<div class="col-sm"> <div class="col-sm">

View File

@@ -22,6 +22,8 @@ import PeersDefaultSettingsInput from "@/components/settingsComponent/peersDefau
targetData="peer_mtu" title="MTU"></PeersDefaultSettingsInput> targetData="peer_mtu" title="MTU"></PeersDefaultSettingsInput>
<PeersDefaultSettingsInput <PeersDefaultSettingsInput
targetData="peer_keep_alive" title="Persistent Keepalive"></PeersDefaultSettingsInput> targetData="peer_keep_alive" title="Persistent Keepalive"></PeersDefaultSettingsInput>
<PeersDefaultSettingsInput
targetData="peer_preshared_key_default" title="Pre-Shared Key Default"></PeersDefaultSettingsInput>
<PeersDefaultSettingsInput <PeersDefaultSettingsInput
targetData="remote_endpoint" title="Peer Remote Endpoint" targetData="remote_endpoint" title="Peer Remote Endpoint"
:warning="true" warningText="This will be changed globally, and will be apply to all peer's QR code and configuration file." :warning="true" warningText="This will be changed globally, and will be apply to all peer's QR code and configuration file."

View File

@@ -31,6 +31,11 @@ export default {
mounted() { mounted() {
this.value = this.store.Configuration.Peers[this.targetData]; this.value = this.store.Configuration.Peers[this.targetData];
}, },
computed: {
isBoolean(){
return typeof this.value === "boolean"
}
},
methods:{ methods:{
async useValidation(){ async useValidation(){
if(this.changed){ if(this.changed){
@@ -67,7 +72,14 @@ export default {
<LocaleText :t="this.title"></LocaleText> <LocaleText :t="this.title"></LocaleText>
</small></strong> </small></strong>
</label> </label>
<input type="text" class="form-control" <div v-if="isBoolean" class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch"
v-model="this.value"
:id="this.uuid"
@change="this.changed = true; useValidation()"
:disabled="this.updating">
</div>
<input v-else type="text" class="form-control"
:class="{'is-invalid': showInvalidFeedback, 'is-valid': isValid}" :class="{'is-invalid': showInvalidFeedback, 'is-valid': isValid}"
:id="this.uuid" :id="this.uuid"
v-model="this.value" v-model="this.value"