Diff

mod_firewall/conditions.lib.lua @ 2128:21bc4d7cddae

mod_firewall: Add support for throttling based on user-defined properties (experimental)
author Matthew Wild <mwild1@gmail.com>
date Fri, 18 Mar 2016 09:47:52 +0000
parent 2127:59023dffbdd4
child 2342:6848297cf40a
line wrap: on
line diff
--- a/mod_firewall/conditions.lib.lua	Fri Mar 18 09:45:02 2016 +0000
+++ b/mod_firewall/conditions.lib.lua	Fri Mar 18 09:47:52 2016 +0000
@@ -182,8 +182,22 @@
 	return table.concat(conditions, " or "), { "time:hour,min" };
 end
 
-function condition_handlers.LIMIT(name)
-	return ("not throttle_%s:poll(1)"):format(name), { "throttle:"..name };
+function condition_handlers.LIMIT(spec)
+	local name, param = spec:match("^(%w+) on (.+)$");
+
+	if not name then
+		name = spec:match("^%w+$");
+		if not name then
+			error("Unable to parse LIMIT specification");
+		end
+	else
+		param = meta(("%q"):format(param));
+	end
+
+	if not param then
+		return ("not global_throttle_%s:poll(1)"):format(name), { "globalthrottle:"..name };
+	end
+	return ("not multi_throttle_%s:poll_on(%s, 1)"):format(name, param), { "multithrottle:"..name };	
 end
 
 function condition_handlers.ORIGIN_MARKED(name_and_time)