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 <this_username_has_been_taken2@proton.me>
This commit is contained in:
Tom Haley
2024-12-05 10:27:38 +03:00
committed by Paul Donald
parent 101ea169c6
commit 27ecfdaafe

View File

@@ -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() {