diff --git a/src/vpnHandler/vpn.js b/src/vpnHandler/vpn.js index 5c016c1..6e8015d 100644 --- a/src/vpnHandler/vpn.js +++ b/src/vpnHandler/vpn.js @@ -5,8 +5,8 @@ const WG_CONF = "/etc/wireguard/wg0.conf"; const PEER_DB = "/etc/wireguard/peers.json"; const CLIENT_DIR = "/etc/wireguard/clients"; -const SERVER_PUBLIC_KEY = ""; -const SERVER_IP = ""; +const SERVER_PUBLIC_KEY = process.env.SERVER_PUBLIC_KEY || ""; +const SERVER_IP = process.env.SERVER_PUBLIC_IP || ""; function loadDb() { try { @@ -69,7 +69,7 @@ function addPeerToServer(publicKey, ip) { 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" }