comparison mod_firewall/definitions.lib.lua @ 2131:ba42c8882026

mod_firewall: Fix another unprotected use of util.cache
author Matthew Wild <mwild1@gmail.com>
date Fri, 18 Mar 2016 09:59:42 +0000
parents 9239893a2400
children 5fe483b73fd2
comparison
equal deleted inserted replaced
2130:9239893a2400 2131:ba42c8882026
4 4
5 local definition_handlers = {}; 5 local definition_handlers = {};
6 6
7 local set = require"util.set"; 7 local set = require"util.set";
8 local new_throttle = require "util.throttle".create; 8 local new_throttle = require "util.throttle".create;
9 local new_cache = require "util.cache".new;
10 9
11 local multirate_cache_size = module:get_option_number("firewall_multirate_cache_limit", 1000); 10 local multirate_cache_size = module:get_option_number("firewall_multirate_cache_limit", 1000);
12 11
13 function definition_handlers.ZONE(zone_name, zone_members) 12 function definition_handlers.ZONE(zone_name, zone_members)
14 local zone_member_list = {}; 13 local zone_member_list = {};
37 single = function () 36 single = function ()
38 return new_throttle(rate*burst, burst); 37 return new_throttle(rate*burst, burst);
39 end; 38 end;
40 39
41 multi = function () 40 multi = function ()
42 local cache = new_cache(max_throttles, evict_only_unthrottled); 41 local cache = require "util.cache".new(max_throttles, evict_only_unthrottled);
43 return { 42 return {
44 poll_on = function (_, key, amount) 43 poll_on = function (_, key, amount)
45 assert(key, "no key"); 44 assert(key, "no key");
46 local throttle = cache:get(key); 45 local throttle = cache:get(key);
47 if not throttle then 46 if not throttle then
57 end; 56 end;
58 }; 57 };
59 end 58 end
60 59
61 return definition_handlers; 60 return definition_handlers;
61