mod_firewall/conditions.lib.lua
changeset 2111 f445f43b9ba1
parent 2079 baa1cb349427
child 2113 9db4113d0cb5
--- a/mod_firewall/conditions.lib.lua	Thu Mar 17 11:26:20 2016 +0000
+++ b/mod_firewall/conditions.lib.lua	Thu Mar 17 11:27:10 2016 +0000
@@ -180,4 +180,18 @@
 	return ("not throttle_%s:poll(1)"):format(name), { "throttle:"..name };
 end
 
+function condition_handlers.ORIGIN_MARKED(name_and_time)
+	local name, time = name_and_time:match("^%s*(%w+)%s+%(([^)]+)s%)%s*$");
+	if not name then
+		name = name_and_time:match("^%s*(%w+)%s*$");
+	end
+	if not name then
+		error("Error parsing mark name, see documentation for usage examples");
+	end
+	if time then
+		return ("(current_time - (session.firewall_marked_%s or 0)) < %d"):format(idsafe(name), tonumber(time)), { "timestamp" };
+	end
+	return ("not not session.firewall_marked_"..idsafe(name));
+end
+
 return condition_handlers;