mod_firewall: Split compile function into two parts in order to separate their scopes
--- a/mod_firewall/mod_firewall.lua Fri Mar 11 18:48:05 2016 +0100
+++ b/mod_firewall/mod_firewall.lua Fri Mar 11 18:48:34 2016 +0100
@@ -134,7 +134,7 @@
return rule;
end
-local function compile_firewall_rules(filename)
+local function parse_firewall_rules(filename)
local line_no = 0;
local function errmsg(err)
@@ -266,7 +266,10 @@
end
end
end
+ return ruleset;
+end
+local function process_firewall_rules(ruleset)
-- Compile ruleset and return complete code
local chain_handlers = {};
@@ -340,6 +343,13 @@
return chain_handlers;
end
+local function compile_firewall_rules(filename)
+ local ruleset, err = parse_firewall_rules(filename);
+ if not ruleset then return nil, err; end
+ local chain_handlers = process_firewall_rules(ruleset);
+ return chain_handlers;
+end
+
local function compile_handler(code_string, filename)
-- Prepare event handler function
local chunk, err = loadstring(code_string, "="..filename);