From 97acd483044002f08904ff165a06f9fd42335b9c Mon Sep 17 00:00:00 2001 From: Sky Zhu Date: Wed, 7 Feb 2024 13:43:01 +0000 Subject: [PATCH] support json configurations without psk --- src/lib/WireGuard.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/WireGuard.js b/src/lib/WireGuard.js index f72c3a23..62afee53 100644 --- a/src/lib/WireGuard.js +++ b/src/lib/WireGuard.js @@ -110,8 +110,8 @@ PostDown = ${WG_POST_DOWN} # Client: ${client.name} (${clientId}) [Peer] PublicKey = ${client.publicKey} -PresharedKey = ${client.preSharedKey} -AllowedIPs = ${client.address}/32`; +${client.preSharedKey ? `PresharedKey = ${client.preSharedKey}\n` : '' +}AllowedIPs = ${client.address}/32`; } debug('Config saving...'); @@ -204,8 +204,8 @@ ${WG_MTU ? `MTU = ${WG_MTU}\n` : ''}\ [Peer] PublicKey = ${config.server.publicKey} -PresharedKey = ${client.preSharedKey} -AllowedIPs = ${WG_ALLOWED_IPS} +${client.preSharedKey ? `PresharedKey = ${client.preSharedKey}\n` : '' +}AllowedIPs = ${WG_ALLOWED_IPS} PersistentKeepalive = ${WG_PERSISTENT_KEEPALIVE} Endpoint = ${WG_HOST}:${WG_PORT}`; }