Software /
code /
prosody-modules
Changeset
960:d773a51af9b1
mod_firewall: Add actions EVENT (fire an event), JUMP EVENT (transfer control to the handlers of an event), JUMP CHAIN (transfer control to another mod_firewall chain)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 05 Apr 2013 18:08:16 +0100 |
parents | 959:6ef334596276 |
children | 961:f0108ec2b016 |
files | mod_firewall/actions.lib.lua mod_firewall/mod_firewall.lua |
diffstat | 2 files changed, 13 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_firewall/actions.lib.lua Fri Apr 05 18:06:32 2013 +0100 +++ b/mod_firewall/actions.lib.lua Fri Apr 05 18:08:16 2013 +0100 @@ -162,4 +162,16 @@ return "", { dep }; end +function action_handlers.EVENT(name) + return ("fire_event(%q, event)"):format(name); +end + +function action_handlers.JUMP_EVENT(name) + return ("do return fire_event(%q, event); end"):format(name); +end + +function action_handlers.JUMP_CHAIN(name) + return ("do return fire_event(%q, event); end"):format("firewall/chains/"..name); +end + return action_handlers;
--- a/mod_firewall/mod_firewall.lua Fri Apr 05 18:06:32 2013 +0100 +++ b/mod_firewall/mod_firewall.lua Fri Apr 05 18:08:16 2013 +0100 @@ -241,9 +241,7 @@ table.insert(code, rule_code); end - assert(chains[chain_name].type == "event", "Only event chains supported at the moment") - - local code_string = [[return function (zones, log) + local code_string = [[return function (zones, fire_event, log) ]]..table.concat(code.global_header, "\n")..[[ local db = require 'util.debug' return function (event)