From 9e94c018c7a0807035fd60811cdbf6854bb0424b Mon Sep 17 00:00:00 2001 From: Tim Wilkinson Date: Sat, 3 Feb 2024 22:32:40 -0800 Subject: [PATCH] Regenerate key when client name changes (#1088) --- files/www/cgi-bin/vpn | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/files/www/cgi-bin/vpn b/files/www/cgi-bin/vpn index 9cf92fdc..f43a30af 100755 --- a/files/www/cgi-bin/vpn +++ b/files/www/cgi-bin/vpn @@ -386,6 +386,12 @@ do break end + -- Generate a new key if we chance the client name + local cname = cursor:get("wireguard", "client_" .. wgclient_num, "name") or "" + local ckey = cursor:get("wireguard", "client_" .. wgclient_num, "key") or "" + if key == ckey and name ~= cname and name ~= "" then + key = "" + end if key == "" then local privS = capture("/usr/bin/wg genkey"):match("(%S+)") local pubS = capture("echo " .. privS .. " | /usr/bin/wg pubkey"):match("(%S+)")