Fix: Remove dns if empty (#2057)

remove dns if empty
This commit is contained in:
Bernd Storath
2025-07-25 11:26:16 +02:00
committed by GitHub
parent b7f9b7c830
commit b5318086d2
+8 -3
View File
@@ -85,14 +85,19 @@ PostDown = ${iptablesTemplate(hooks.postDown, wgInterface)}`;
client.postUp ? `PostUp = ${client.postUp}` : null, client.postUp ? `PostUp = ${client.postUp}` : null,
client.preDown ? `PreDown = ${client.preDown}` : null, client.preDown ? `PreDown = ${client.preDown}` : null,
client.postDown ? `PostDown = ${client.postDown}` : null, client.postDown ? `PostDown = ${client.postDown}` : null,
].filter((v) => v !== null); ];
const dnsServers = client.dns ?? userConfig.defaultDns;
const dnsLine =
dnsServers.length > 0 ? `DNS = ${dnsServers.join(', ')}` : null;
const extraLines = [dnsLine, ...hookLines].filter((v) => v !== null);
return `[Interface] return `[Interface]
PrivateKey = ${client.privateKey} PrivateKey = ${client.privateKey}
Address = ${address} Address = ${address}
DNS = ${(client.dns ?? userConfig.defaultDns).join(', ')}
MTU = ${client.mtu} MTU = ${client.mtu}
${hookLines.length ? `${hookLines.join('\n')}\n` : ''} ${extraLines.length ? `${extraLines.join('\n')}\n` : ''}
[Peer] [Peer]
PublicKey = ${wgInterface.publicKey} PublicKey = ${wgInterface.publicKey}
PresharedKey = ${client.preSharedKey} PresharedKey = ${client.preSharedKey}