aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2023-12-08 13:36:51 +0000
committerMatthew Wild <mwild1@gmail.com>2023-12-08 13:36:51 +0000
commitc2d0d411d4e5b3b701da89d8f29cd37ea1a64bf1 (patch)
treef71c193bb86623590f4278379adc3fa092c81dfc
parent39d85bbc3184be315c52c491c75bd77e60b133d9 (diff)
downloadprosody-c2d0d411d4e5b3b701da89d8f29cd37ea1a64bf1.tar.gz
prosody-c2d0d411d4e5b3b701da89d8f29cd37ea1a64bf1.zip
configmanager: Allow referencing previously-set options in the config file
-rw-r--r--core/configmanager.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/core/configmanager.lua b/core/configmanager.lua
index 951f61fd..9a66ad13 100644
--- a/core/configmanager.lua
+++ b/core/configmanager.lua
@@ -62,6 +62,16 @@ local function set(config_table, host, key, value)
return false;
end
+local function rawget_option(config_table, host, key)
+ if host and key then
+ local hostconfig = rawget(config_table, host);
+ if not hostconfig then
+ return nil;
+ end
+ return rawget(hostconfig, key);
+ end
+end
+
function _M.set(host, key, value)
return set(config, host, key, value);
end
@@ -119,6 +129,10 @@ do
if k:match("^ENV_") then
return os.getenv(k:sub(5));
end
+ local val = rawget_option(config_table, env.__currenthost or "*", k);
+ if val ~= nil then
+ return val;
+ end
return rawget(_G, k);
end,
__newindex = function (_, k, v)