# HG changeset patch # User Matthew Wild # Date 1458295029 0 # Node ID 9239893a24003c2af81710355c7fff3b7e746d1e # Parent 26334f4a8eb90a6e424a55e6a7dfa65618d43ab0 mod_firewall: Don't use util.cache unless it's needed, and add explanatory error if it is not available diff -r 26334f4a8eb9 -r 9239893a2400 mod_firewall/definitions.lib.lua --- a/mod_firewall/definitions.lib.lua Fri Mar 18 09:51:01 2016 +0000 +++ b/mod_firewall/definitions.lib.lua Fri Mar 18 09:57:09 2016 +0000 @@ -33,14 +33,13 @@ 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 cache = new_cache(max_throttles, evict_only_unthrottled); - return { single = function () return new_throttle(rate*burst, burst); end; multi = function () + local cache = new_cache(max_throttles, evict_only_unthrottled); return { poll_on = function (_, key, amount) assert(key, "no key"); diff -r 26334f4a8eb9 -r 9239893a2400 mod_firewall/mod_firewall.lua --- a/mod_firewall/mod_firewall.lua Fri Mar 18 09:51:01 2016 +0000 +++ b/mod_firewall/mod_firewall.lua Fri Mar 18 09:57:09 2016 +0000 @@ -117,6 +117,7 @@ }; multithrottle = { global_code = function (throttle) + assert(pcall(require, "util.cache"), "Using LIMIT with 'on' requires Prosody 0.10 or higher"); assert(idsafe(throttle), "Invalid rate limit name: "..throttle); assert(active_definitions.RATE[throttle], "Unknown rate limit: "..throttle); return ("local multi_throttle_%s = rates.%s:multi();"):format(throttle, throttle);