Regenerate key when client name changes (#1088)

This commit is contained in:
Tim Wilkinson 2024-02-03 22:32:40 -08:00 committed by GitHub
parent 14929ff576
commit 9e94c018c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 0 deletions

View File

@ -386,6 +386,12 @@ do
break break
end 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 if key == "" then
local privS = capture("/usr/bin/wg genkey"):match("(%S+)") local privS = capture("/usr/bin/wg genkey"):match("(%S+)")
local pubS = capture("echo " .. privS .. " | /usr/bin/wg pubkey"):match("(%S+)") local pubS = capture("echo " .. privS .. " | /usr/bin/wg pubkey"):match("(%S+)")