Changeset

2531:9d2bfff515b8

mod_firewall: Add 'ADD TO' action for adding to lists
author Matthew Wild <mwild1@gmail.com>
date Mon, 20 Feb 2017 09:47:58 +0000
parents 2530:84e103fd8039
children 2532:2ddb74805f91
files mod_firewall/actions.lib.lua
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mod_firewall/actions.lib.lua	Mon Feb 20 09:47:40 2017 +0000
+++ b/mod_firewall/actions.lib.lua	Mon Feb 20 09:47:58 2017 +0000
@@ -187,4 +187,11 @@
 	return [[session.firewall_marked_]]..idsafe(name)..[[ = nil;]]
 end
 
+function action_handlers.ADD_TO(spec)
+	local list_name, value = spec:match("(%S+) (.+)");
+	local meta_deps = {};
+	value = meta(("%q"):format(value), meta_deps);
+	return ("list_%s:add(%s);"):format(list_name, value), { "list:"..list_name, unpack(meta_deps) };
+end
+
 return action_handlers;