1
0
mirror of https://github.com/donaldzou/WGDashboard.git synced 2024-11-22 07:10:09 +01:00

Preshared Key switch is added for both single and bullk add peers

This commit is contained in:
Donald Zou 2024-09-05 17:10:24 +08:00
parent bcc983f11f
commit ec50dcbbd9
2 changed files with 17 additions and 3 deletions

View File

@ -1792,6 +1792,7 @@ def API_addPeers(configName):
mtu = data['mtu']
keep_alive = data['keepalive']
preshared_key = data['preshared_key']
preshared_key_bulkAdd: bool = data['preshared_key_bulkAdd']
if configName in WireguardConfigurations.keys():
config = WireguardConfigurations.get(configName)
@ -1818,7 +1819,7 @@ def API_addPeers(configName):
keyPairs.append({
"private_key": newPrivateKey,
"id": _generatePublicKey(newPrivateKey)[1],
"preshared_key": _generatePrivateKey()[1],
"preshared_key": (_generatePrivateKey()[1] if preshared_key_bulkAdd else ""),
"allowed_ip": availableIps[1][i],
"name": f"BulkPeer #{(i + 1)}_{datetime.now().strftime('%Y%m%d_%H%M%S')}"
})

View File

@ -33,7 +33,8 @@ export default {
endpoint_allowed_ip: this.dashboardStore.Configuration.Peers.peer_endpoint_allowed_ip,
keepalive: parseInt(this.dashboardStore.Configuration.Peers.peer_keep_alive),
mtu: parseInt(this.dashboardStore.Configuration.Peers.peer_mtu),
preshared_key: ""
preshared_key: "",
preshared_key_bulkAdd: false
},
availableIp: undefined,
availableIpSearchString: "",
@ -119,16 +120,28 @@ export default {
<DnsInput :saving="saving" :data="data"></DnsInput>
<hr class="mb-0 mt-2">
<div class="row">
<div class="row gy-3">
<div class="col-sm" v-if="!this.data.bulkAdd">
<PresharedKeyInput :saving="saving" :data="data" :bulk="this.data.bulkAdd"></PresharedKeyInput>
</div>
<div class="col-sm">
<MtuInput :saving="saving" :data="data"></MtuInput>
</div>
<div class="col-sm">
<PersistentKeepAliveInput :saving="saving" :data="data"></PersistentKeepAliveInput>
</div>
<div class="col-12" v-if="this.data.bulkAdd">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch"
v-model="this.data.preshared_key_bulkAdd"
id="bullAdd_PresharedKey_Switch" checked>
<label class="form-check-label" for="bullAdd_PresharedKey_Switch">
Pre-Share Key
{{this.data.preshared_key_bulkAdd ? "Enabled":"Disabled"}}
</label>
</div>
</div>
</div>
<div class="d-flex mt-2">
<button class="ms-auto btn btn-dark btn-brand rounded-3 px-3 py-2 shadow"