Comparison

mod_firewall/mod_firewall.lua @ 2100:cbd0095e9302

mod_firewall: Add 'timestamp' dep to get current_timestamp
author Matthew Wild <mwild1@gmail.com>
date Thu, 17 Mar 2016 11:22:35 +0000
parent 2099:a8c701631d0b
child 2101:41a0a9db89ef
comparison
equal deleted inserted replaced
2099:a8c701631d0b 2100:cbd0095e9302
78 for field in what:gmatch("%a+") do 78 for field in what:gmatch("%a+") do
79 table.insert(defs, ("local current_%s = current_date_time.%s;"):format(field, field)); 79 table.insert(defs, ("local current_%s = current_date_time.%s;"):format(field, field));
80 end 80 end
81 return table.concat(defs, " "); 81 return table.concat(defs, " ");
82 end, depends = { "date_time" }; }; 82 end, depends = { "date_time" }; };
83 timestamp = { global_code = [[local get_time = require "socket".gettime]]; local_code = [[local current_timestamp = get_time()]]; };
83 throttle = { 84 throttle = {
84 global_code = function (throttle) 85 global_code = function (throttle)
85 assert(idsafe(throttle), "Invalid rate limit name: "..throttle); 86 assert(idsafe(throttle), "Invalid rate limit name: "..throttle);
86 assert(active_definitions.RATE[throttle], "Unknown rate limit: "..throttle); 87 assert(active_definitions.RATE[throttle], "Unknown rate limit: "..throttle);
87 return ("local throttle_%s = rates.%s;"):format(throttle, throttle); 88 return ("local throttle_%s = rates.%s;"):format(throttle, throttle);