WireGuard.js: remove redundant newline char in client config generation

This commit is contained in:
Minghong Xu 2024-01-30 06:59:19 +00:00
parent bfd281fc9f
commit 8aafe6b8c9
1 changed files with 9 additions and 6 deletions

View File

@ -196,19 +196,22 @@ AllowedIPs = ${client.address}/32`;
const config = await this.getConfig();
const client = await this.getClient({ clientId });
return `
[Interface]
const interface = `[Interface]
PrivateKey = ${client.privateKey}
Address = ${client.address}/24
${WG_DEFAULT_DNS ? `DNS = ${WG_DEFAULT_DNS}` : ''}
${WG_MTU ? `MTU = ${WG_MTU}` : ''}
${WG_DEFAULT_DNS ? `DNS = ${WG_DEFAULT_DNS}\n` : ''}\
${WG_MTU ? `MTU = ${WG_MTU}\n` : ''}\
`;
[Peer]
const peer = `[Peer]
PublicKey = ${config.server.publicKey}
PresharedKey = ${client.preSharedKey}
AllowedIPs = ${WG_ALLOWED_IPS}
PersistentKeepalive = ${WG_PERSISTENT_KEEPALIVE}
Endpoint = ${WG_HOST}:${WG_PORT}`;
Endpoint = ${WG_HOST}:${WG_PORT}
`;
return [interface, peer].join('\n');
}
async getClientQRCodeSVG({ clientId }) {