From 857f0cb64c017a3613f1beb873c27082d4c24a94 Mon Sep 17 00:00:00 2001 From: Alireza Ahmadi Date: Tue, 20 Feb 2024 21:11:12 +0100 Subject: [PATCH] [wg] fix subnet in peer --- web/assets/js/model/xray.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/web/assets/js/model/xray.js b/web/assets/js/model/xray.js index bb0250c5..79fe0b1c 100644 --- a/web/assets/js/model/xray.js +++ b/web/assets/js/model/xray.js @@ -2124,7 +2124,7 @@ Inbound.WireguardSettings = class extends XrayCommonClass { }; Inbound.WireguardSettings.Peer = class extends XrayCommonClass { - constructor(privateKey, publicKey, psk='', allowedIPs=['10.0.0.0/24'], keepAlive=0) { + constructor(privateKey, publicKey, psk='', allowedIPs=['10.0.0.2/32'], keepAlive=0) { super(); this.privateKey = privateKey this.publicKey = publicKey; @@ -2132,6 +2132,9 @@ Inbound.WireguardSettings.Peer = class extends XrayCommonClass { [this.publicKey, this.privateKey] = Object.values(Wireguard.generateKeypair()) } this.psk = psk; + allowedIPs.forEach((a,index) => { + if (a.length>0 && !a.includes('/')) allowedIPs[index] += '/32'; + }) this.allowedIPs = allowedIPs; this.keepAlive = keepAlive; } @@ -2147,6 +2150,9 @@ Inbound.WireguardSettings.Peer = class extends XrayCommonClass { } toJson() { + this.allowedIPs.forEach((a,index) => { + if (a.length>0 && !a.includes('/')) this.allowedIPs[index] += '/32'; + }); return { privateKey: this.privateKey, publicKey: this.publicKey,