diff mod_limit_auth/mod_limit_auth.lua @ 1854:450ada5bb1b5

mod_limit_auth: Get rid of old inactive throttle objects
author Kim Alvefur <zash@zash.se>
date Mon, 14 Sep 2015 13:03:02 +0200
parents c1bb2a64aabb
children 2a5a44d5b935
line wrap: on
line diff
--- a/mod_limit_auth/mod_limit_auth.lua	Mon Sep 14 12:59:48 2015 +0200
+++ b/mod_limit_auth/mod_limit_auth.lua	Mon Sep 14 13:03:02 2015 +0200
@@ -46,4 +46,12 @@
 	get_throttle(event.session.ip):poll(1);
 end);
 
--- TODO remove old throttles after some time
+module:add_timer(14400, function (now)
+	local old = now - 86400;
+	for ip, throttle in pairs(throttles) do
+		if throttle.t < old then
+			throttles[ip] = nil;
+		end
+	end
+end);
+