Diff

mod_firewall/conditions.lib.lua @ 2520:c6fd8975704b

mod_firewall: Initial support for lists, in-memory and HTTP
author Matthew Wild <mwild1@gmail.com>
date Sun, 19 Feb 2017 21:10:26 +0000
parent 2519:d4bc434a60a4
child 2521:66b81e144ded
line wrap: on
line diff
--- a/mod_firewall/conditions.lib.lua	Sun Feb 19 21:08:30 2017 +0000
+++ b/mod_firewall/conditions.lib.lua	Sun Feb 19 21:10:26 2017 +0000
@@ -252,4 +252,15 @@
 	return ("not not session.firewall_marked_"..idsafe(name));
 end
 
+-- CHECK LIST: spammers contains $<@from>
+function condition_handlers.CHECK_LIST(list_condition)
+	local list_name, expr = list_condition:match("(%S+) contains (.+)$");
+	if not list_name and expr then
+		error("Error parsing list check, syntax: LISTNAME contains EXPRESSION");
+	end
+	local meta_deps = {};
+	expr = meta(("%q"):format(expr), meta_deps);
+	return ("list_%s:contains(%s) == true"):format(list_name, expr), { "list:"..list_name, unpack(meta_deps) };
+end
+
 return condition_handlers;