only generate new private key when no valid key is present
This commit is contained in:
parent
2a5f8f80cb
commit
fefdb69763
|
@ -17,16 +17,19 @@ function f.handle(self, state, data)
|
||||||
uci:commit("fastd")
|
uci:commit("fastd")
|
||||||
|
|
||||||
if data.meshvpn == "1" then
|
if data.meshvpn == "1" then
|
||||||
luci.sys.call("/etc/init.d/haveged start")
|
local secret = uci:get("fastd", "ffhl_mesh_vpn", "secret")
|
||||||
local f = io.popen("fastd --generate-key --machine-readable", "r")
|
if not secret or not secret:match("%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x") then
|
||||||
local secret = f:read("*a")
|
luci.sys.call("/etc/init.d/haveged start")
|
||||||
f:close()
|
local f = io.popen("fastd --generate-key --machine-readable", "r")
|
||||||
luci.sys.call("/etc/init.d/haveged stop")
|
local secret = f:read("*a")
|
||||||
|
f:close()
|
||||||
|
luci.sys.call("/etc/init.d/haveged stop")
|
||||||
|
|
||||||
uci:set("fastd", "ffhl_mesh_vpn", "secret", secret)
|
uci:set("fastd", "ffhl_mesh_vpn", "secret", secret)
|
||||||
uci:save("fastd")
|
uci:save("fastd")
|
||||||
uci:commit("fastd")
|
uci:commit("fastd")
|
||||||
|
|
||||||
|
end
|
||||||
luci.http.redirect(luci.dispatcher.build_url("wizard", "meshvpn", "pubkey"))
|
luci.http.redirect(luci.dispatcher.build_url("wizard", "meshvpn", "pubkey"))
|
||||||
else
|
else
|
||||||
nav.maybe_redirect_to_successor()
|
nav.maybe_redirect_to_successor()
|
||||||
|
|
Loading…
Reference in New Issue