mirror of
https://github.com/openwrt/luci.git
synced 2025-12-21 19:14:34 +04:00
luci-proto-wireguard: Fix incorrect peer detection for IP v6
This commit fixes incorrect peer detection when using IP v6 by deleting all the square the square brackets from the wgHost variable. Signed-off-by: Tom Haley <this_username_has_been_taken2@proton.me>
This commit is contained in:
@@ -17,10 +17,11 @@ function command(cmd) {
|
|||||||
|
|
||||||
function checkPeerHost(configHost, configPort, wgHost) {
|
function checkPeerHost(configHost, configPort, wgHost) {
|
||||||
const ips = popen(`resolveip ${configHost} 2>/dev/null`);
|
const ips = popen(`resolveip ${configHost} 2>/dev/null`);
|
||||||
|
const hostIp = replace(wgHost, /\[|\]/g, "");
|
||||||
if (ips) {
|
if (ips) {
|
||||||
for (let line = ips.read('line'); length(line); line = ips.read('line')) {
|
for (let line = ips.read('line'); length(line); line = ips.read('line')) {
|
||||||
const ip = rtrim(line, '\n');
|
const ip = rtrim(line, '\n');
|
||||||
if (ip + ":" + configPort == wgHost) {
|
if (ip + ":" + configPort == hostIp) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user