Browse Source

added multiple allowed IPs support via wg0.json

pull/1676/head
sheikhmishar 6 months ago
parent
commit
d1d70ee908
  1. 2
      README.md
  2. 16
      src/lib/WireGuard.js

2
README.md

@ -94,7 +94,7 @@ The Web UI will now be available on `http://0.0.0.0:51821`.
The Prometheus metrics will now be available on `http://0.0.0.0:51821/metrics`. Grafana dashboard [21733](https://grafana.com/grafana/dashboards/21733-wireguard/)
> 💡 Your configuration files will be saved in `~/.wg-easy`
> 💡 Your configuration files will be saved in `~/.wg-easy`. You can modify `wg0.json` file for per client configuration. `extraAllowedIPs` and `serverPeerAllowedIPs` can be used for multi-network/gateway support
WireGuard Easy can be launched with Docker Compose as well - just download
[`docker-compose.yml`](docker-compose.yml), make necessary adjustments and

16
src/lib/WireGuard.js

@ -79,10 +79,6 @@ module.exports = class WireGuard {
throw err;
});
// await Util.exec(`iptables -t nat -A POSTROUTING -s ${WG_DEFAULT_ADDRESS.replace('x', '0')}/24 -o ' + WG_DEVICE + ' -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();
}
@ -120,7 +116,9 @@ PostDown = ${WG_POST_DOWN}
[Peer]
PublicKey = ${client.publicKey}
${client.preSharedKey ? `PresharedKey = ${client.preSharedKey}\n` : ''
}AllowedIPs = ${client.address}/32`;
}AllowedIPs = ${client.address}/32${
client.serverPeerAllowedIPs ? "," + client.serverPeerAllowedIPs : ""
}`;
}
debug('Config saving...');
@ -153,6 +151,8 @@ ${client.preSharedKey ? `PresharedKey = ${client.preSharedKey}\n` : ''
? new Date(client.expiredAt)
: null,
allowedIPs: client.allowedIPs,
extraAllowedIPs: client.extraAllowedIPs || '',
serverPeerAllowedIPs: client.serverPeerAllowedIPs || '',
oneTimeLink: client.oneTimeLink ?? null,
oneTimeLinkExpiresAt: client.oneTimeLinkExpiresAt ?? null,
downloadableConfig: 'privateKey' in client,
@ -222,7 +222,9 @@ ${WG_MTU ? `MTU = ${WG_MTU}\n` : ''}\
[Peer]
PublicKey = ${config.server.publicKey}
${client.preSharedKey ? `PresharedKey = ${client.preSharedKey}\n` : ''
}AllowedIPs = ${WG_ALLOWED_IPS}
}AllowedIPs = ${WG_ALLOWED_IPS}${
client.extraAllowedIPs ? (',' + client.extraAllowedIPs) : ''
}
PersistentKeepalive = ${WG_PERSISTENT_KEEPALIVE}
Endpoint = ${WG_HOST}:${WG_CONFIG_PORT}`;
}
@ -273,6 +275,8 @@ Endpoint = ${WG_HOST}:${WG_CONFIG_PORT}`;
privateKey,
publicKey,
preSharedKey,
extraAllowedIPs: '',
serverPeerAllowedIPs: '',
createdAt: new Date(),
updatedAt: new Date(),

Loading…
Cancel
Save