# HG changeset patch # User Marco Cirillo # Date 1328747071 0 # Node ID 1004d7176be287a290aa0c57a6712cc0349a9fb0 # Parent 1c2fc3b845f266fae33f1bfb5358a781fb90a484 mod_register_json: cleanup unused stuff diff -r 1c2fc3b845f2 -r 1004d7176be2 mod_register_json/mod_register_json.lua --- a/mod_register_json/mod_register_json.lua Thu Jan 26 19:38:03 2012 +0100 +++ b/mod_register_json/mod_register_json.lua Thu Feb 09 00:24:31 2012 +0000 @@ -75,17 +75,14 @@ if blacklist:contains(req_body["ip"]) then module:log("warn", "Attempt of reg. submission to the JSON servlet from blacklisted address: %s", req_body["ip"]) ; return http_response(403, "The specified address is blacklisted, sorry sorry.") end if throttle_time and not whitelist:contains(req_body["ip"]) then if not recent_ips[req_body["ip"]] then - recent_ips[req_body["ip"]] = { time = os_time(), count = 1 } + recent_ips[req_body["ip"]] = os_time() else - local ip = recent_ips[req_body["ip"]] - ip.count = ip.count + 1 - - if os_time() - ip.time < throttle_time then - ip.time = os_time() + if os_time() - recent_ips[req_body["ip"]] < throttle_time then + recent_ips[req_body["ip"]] = os_time() module:log("warn", "JSON Registration request from %s has been throttled.", req_body["ip"]) return http_response(503, "Woah... How many users you want to register..? Request throttled, wait a bit and try again.") end - ip.time = os_time() + recent_ips[req_body["ip"]] = os_time() end end