Software /
code /
prosody-modules
Diff
mod_firewall/mod_firewall.lua @ 2078:11539785cb92
mod_firewall: Split compile function into two parts in order to separate their scopes
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 11 Mar 2016 18:48:34 +0100 |
parent | 2077:368b091e723b |
child | 2080:a435db77a5e5 |
line wrap: on
line diff
--- 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);