This commit is contained in:
=bhagwanSingh 2025-12-16 07:29:45 +05:30
parent e79383c1cf
commit fd382ccb93
1 changed files with 10 additions and 9 deletions

View File

@ -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" }