diff mod_firewall/definitions.lib.lua @ 2370:5fe483b73fd2

mod_firewall: Rate limiting: Document 'entries' and add option to allow overflowing when full
author Matthew Wild <mwild1@gmail.com>
date Tue, 15 Nov 2016 21:55:12 +0000
parents ba42c8882026
children c6fd8975704b
line wrap: on
line diff
--- a/mod_firewall/definitions.lib.lua	Tue Nov 15 21:02:46 2016 +0000
+++ b/mod_firewall/definitions.lib.lua	Tue Nov 15 21:55:12 2016 +0000
@@ -31,14 +31,14 @@
 			local rate = assert(tonumber(line:match("([%d.]+)")), "Unable to parse rate");
 			local burst = tonumber(line:match("%(%s*burst%s+([%d.]+)%s*%)")) or 1;
 			local max_throttles = tonumber(line:match("%(%s*entries%s+([%d]+)%s*%)")) or multirate_cache_size;
-
+			local deny_when_full = not line:match("%(allow overflow%)");
 			return {
 				single = function ()
 					return new_throttle(rate*burst, burst);
 				end;
 				
 				multi = function ()
-					local cache = require "util.cache".new(max_throttles, evict_only_unthrottled);
+					local cache = require "util.cache".new(max_throttles, deny_when_full and evict_only_unthrottled or nil);
 					return {
 						poll_on = function (_, key, amount)
 							assert(key, "no key");