aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--awall/init.lua30
1 files changed, 30 insertions, 0 deletions
diff --git a/awall/init.lua b/awall/init.lua
index 4635ff8..8f3212d 100644
--- a/awall/init.lua
+++ b/awall/init.lua
@@ -55,6 +55,36 @@ function translate()
end
end
+
+ function expandvars(obj)
+ for k, v in pairs(obj) do
+ if type(v) == 'table' then
+ expandvars(v)
+
+ else
+ local visited = {}
+ local val = v
+
+ while type(val) == 'string' and string.sub(val, 1, 1) == '$' do
+ local name = string.sub(val, 2, -1)
+
+ if util.contains(visited, name) then
+ error('Circular variable definition: '..name)
+ end
+ table.insert(visited, name)
+
+ val = config.variable[name]
+ if not val then error('Invalid variable reference: '..name) end
+ end
+
+ obj[k] = val
+ end
+ end
+ end
+
+ expandvars(config)
+
+
function insertrule(trule)
local t = awall.iptables.config[trule.family][trule.table][trule.chain]
if trule.position == 'prepend' then