From 27ecfdaafe344a79ed32a5b5dc1fddf8f811f91d Mon Sep 17 00:00:00 2001 From: Tom Haley Date: Thu, 5 Dec 2024 10:27:38 +0300 Subject: [PATCH] luci-proto-wireguard: fixed incorrect peer detection if port is not set Fixed incorrect peer detection if port is not set (default port is used) Signed-off-by: Tom Haley --- .../root/usr/share/rpcd/ucode/luci.wireguard | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/protocols/luci-proto-wireguard/root/usr/share/rpcd/ucode/luci.wireguard b/protocols/luci-proto-wireguard/root/usr/share/rpcd/ucode/luci.wireguard index 4d2a5912b7..32acbb639d 100644 --- a/protocols/luci-proto-wireguard/root/usr/share/rpcd/ucode/luci.wireguard +++ b/protocols/luci-proto-wireguard/root/usr/share/rpcd/ucode/luci.wireguard @@ -21,7 +21,9 @@ function checkPeerHost(configHost, configPort, wgHost) { if (ips) { for (let line = ips.read('line'); length(line); line = ips.read('line')) { const ip = rtrim(line, '\n'); - if (ip + ":" + configPort == hostIp) { + if (configPort && (ip + ":" + configPort == hostIp)) { + return true; + } else if (ip == substr(hostIp, 0, index(hostIp, ":"))) { return true; } } @@ -29,7 +31,6 @@ function checkPeerHost(configHost, configPort, wgHost) { return false; } - const methods = { generatePsk: { call: function() { -- 2.30.2