From: Tom Haley Date: Thu, 5 Dec 2024 07:27:38 +0000 (+0300) Subject: luci-proto-wireguard: fixed incorrect peer detection if port is not set X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=27ecfdaafe344a79ed32a5b5dc1fddf8f811f91d;p=project%2Fluci.git 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 --- 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() {