diff --git a/src/vpnHandler/vpn.js b/src/vpnHandler/vpn.js index de18998..5c016c1 100644 --- a/src/vpnHandler/vpn.js +++ b/src/vpnHandler/vpn.js @@ -58,17 +58,18 @@ function generateKeyPair() { // } function addPeerToServer(publicKey, ip) { - // const peerEntry = ` - // [Peer] - // PublicKey = ${publicKey} - // AllowedIPs = ${ip}/32 - // `; + const peerEntry = ` + [Peer] + PublicKey = ${publicKey} + AllowedIPs = ${ip}/32 + `; - // fs.appendFileSync(WG_CONF, peerEntry); + fs.appendFileSync(WG_CONF, peerEntry); - // execSync("wg-quick strip wg0 > /tmp/wg0.tmp"); - // execSync("wg syncconf wg0 /tmp/wg0.tmp"); - // execSync("rm -f /tmp/wg0.tmp"); + execSync("wg-quick strip wg0 > /tmp/wg0.tmp"); + execSync("wg syncconf wg0 /tmp/wg0.tmp"); + execSync("rm -f /tmp/wg0.tmp"); + execSync( `wg set wg0 peer ${publicKey} allowed-ips ${ip}/32`, { stdio: "inherit" }