From: this-username-has-been-taken Date: Sun, 13 Apr 2025 13:38:46 +0000 (+0300) Subject: luci-proto-wireguard: fixed incorrect peer name detection X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=fee5112940c2dd718742ec9f1dde8cdc01598459;p=project%2Fluci.git luci-proto-wireguard: fixed incorrect peer name detection Added the legacy peer name detection algorithm. If the new algorithm fails to find a peer's name (e.g. when the IP address has been changed) then the legacy value will be used. Signed-off-by: Tom Haley (cherry picked from commit 8bff54dc47057e36c0ceb263efe4c82580003924) (cherry picked from commit f8dea77b35f082fc7e326f3207560164ebc2b7e3) --- 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 55f0bba2a9..b8e20daf94 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 @@ -89,12 +89,17 @@ const methods = { } else { let peer_name; + let peer_name_legacy; uci.foreach('network', `wireguard_${last_device}`, (s) => { if (!s.disabled && s.public_key == record[1] && (!s.endpoint_host || checkPeerHost(s.endpoint_host, s.endpoint_port, record[3]))) peer_name = s.description; + if (s.public_key == record[1]) + peer_name_legacy = s.description; }); + if (!peer_name) peer_name = peer_name_legacy; + const peer = { name: peer_name, public_key: record[1],