Browse Source

Make PresharedKey optional

(if editing config manually)
pull/558/head
Iain MacDonald 3 years ago
parent
commit
dd381b8e07
  1. 16
      src/lib/WireGuard.js

16
src/lib/WireGuard.js

@ -110,8 +110,12 @@ PostDown = ${WG_POST_DOWN}
# Client: ${client.name} (${clientId})
[Peer]
PublicKey = ${client.publicKey}
PresharedKey = ${client.preSharedKey}
AllowedIPs = ${client.address}/32`;
if (client.preSharedKey) {
result += `
PresharedKey = ${client.preSharedKey}`;
}
}
debug('Config saving...');
@ -196,7 +200,7 @@ AllowedIPs = ${client.address}/32`;
const config = await this.getConfig();
const client = await this.getClient({ clientId });
return `
let result = `
[Interface]
PrivateKey = ${client.privateKey}
Address = ${client.address}/24
@ -205,10 +209,16 @@ ${WG_MTU ? `MTU = ${WG_MTU}` : ''}
[Peer]
PublicKey = ${config.server.publicKey}
PresharedKey = ${client.preSharedKey}
AllowedIPs = ${WG_ALLOWED_IPS}
PersistentKeepalive = ${WG_PERSISTENT_KEEPALIVE}
Endpoint = ${WG_HOST}:${WG_PORT}`;
if (client.preSharedKey) {
result += `
PresharedKey = ${client.preSharedKey}`;
}
return result;
}
async getClientQRCodeSVG({ clientId }) {

Loading…
Cancel
Save