Add PreUp, PostUp, PreDown, PostDown for client (#1714)

* Fix create client popup background is not white

* Fix no Add button when client Allowed Ips or Server Allowed Ips is empty

* Add preUp preDown postUp postDown for client

* Add description of hooks for client config

* Move hooks's label text into 'hooks' in en.json

---------

Co-authored-by: yanghuanglin <yanghuanglin@qq.com>
Co-authored-by: Bernd Storath <999999bst@gmail.com>
This commit is contained in:
杨黄林
2025-03-07 15:17:33 +08:00
committed by GitHub
parent 93db67bab6
commit fcb5049dab
14 changed files with 171 additions and 25 deletions

View File

@@ -49,12 +49,19 @@ PostDown = ${iptablesTemplate(hooks.postDown, wgInterface)}`;
const cidr4Block = parseCidr(wgInterface.ipv4Cidr).prefix;
const cidr6Block = parseCidr(wgInterface.ipv6Cidr).prefix;
const hookLines = [
client.preUp ? `PreUp = ${client.preUp}` : null,
client.postUp ? `PostUp = ${client.postUp}` : null,
client.preDown ? `PreDown = ${client.preDown}` : null,
client.postDown ? `PostDown = ${client.postDown}` : null,
].filter((v) => v !== null);
return `[Interface]
PrivateKey = ${client.privateKey}
Address = ${client.ipv4Address}/${cidr4Block}, ${client.ipv6Address}/${cidr6Block}
DNS = ${client.dns.join(', ')}
MTU = ${client.mtu}
${hookLines.length ? `${hookLines.join('\n')}\n` : ''}
[Peer]
PublicKey = ${wgInterface.publicKey}
PresharedKey = ${client.preSharedKey}