[enh] Add persistent rules (as conf.json.persistent)

This commit is contained in:
kload 2014-04-10 18:42:43 +00:00
parent 5c6c8fdf39
commit 8d53f1b366

View file

@ -10,8 +10,30 @@ if not srvkey then
end
oneweek = 60 * 60 * 24 * 7
cookies = {}
-- Load conf file
local conf_file = assert(io.open(conf_path, "r"), "Configuration file is missing")
local conf = json.decode(conf_file:read("*all"))
-- Load additional rules
local persistent_conf_file = io.open(conf_path..".persistent", "r")
if persistent_conf_file ~= nil then
for k, v in pairs(json.decode(persistent_conf_file:read("*all"))) do
-- If key already exists and is an table, merge it
if conf[k] and type(v) == "table" then
for subk, subv in pairs(v) do
if type(subk) == "number" then
table.insert(conf[k], subv)
else
conf[k][subk] = subv
end
end
else
conf[k] = v
end
end
end
local portal_url = conf["portal_scheme"].."://"..
conf["portal_domain"]..
conf["portal_path"]