aniqueta
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
4 additions and
5 deletions
-
src/lib/WireGuard.js
|
|
|
@ -52,10 +52,6 @@ module.exports = class WireGuard { |
|
|
|
|
|
|
|
await this.__saveConfig(config); |
|
|
|
await Util.exec('wg-quick up wg0'); |
|
|
|
await Util.exec(`iptables -t nat -A POSTROUTING -s ${WG_DEFAULT_ADDRESS.replace('x', '0')}/24 -o eth0 -j MASQUERADE`); |
|
|
|
await Util.exec('iptables -A INPUT -p udp -m udp --dport 51820 -j ACCEPT'); |
|
|
|
await Util.exec('iptables -A FORWARD -i wg0 -j ACCEPT'); |
|
|
|
await Util.exec('iptables -A FORWARD -o wg0 -j ACCEPT'); |
|
|
|
await this.__syncConfig(); |
|
|
|
|
|
|
|
return config; |
|
|
|
@ -80,7 +76,10 @@ module.exports = class WireGuard { |
|
|
|
[Interface] |
|
|
|
PrivateKey = ${config.server.privateKey} |
|
|
|
Address = ${config.server.address}/24 |
|
|
|
ListenPort = 51820`;
|
|
|
|
ListenPort = 51820` |
|
|
|
|
|
|
|
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -A FORWARD -o wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -s ${WG_DEFAULT_ADDRESS.replace('x', '0')}/24 -o eth0 -j MASQUERADE iptables -A INPUT -p udp -m udp --dport 51820 -j ACCEPT |
|
|
|
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -D FORWARD -o wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -s ${WG_DEFAULT_ADDRESS.replace('x', '0')}/24 -o eth0 -j MASQUERADE` iptables -D INPUT -p udp -m udp --dport 51820 -j ACCEPT;
|
|
|
|
|
|
|
|
for (const [clientId, client] of Object.entries(config.clients)) { |
|
|
|
if (!client.enabled) continue; |
|
|
|
|