diff mod_limits_exception/mod_limits_exception.lua @ 4562:28c16c93d79a

mod_limits_exception: New module to except some JIDs from rate limiting
author Matthew Wild <mwild1@gmail.com>
date Mon, 24 May 2021 15:46:11 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_limits_exception/mod_limits_exception.lua	Mon May 24 15:46:11 2021 +0100
@@ -0,0 +1,17 @@
+local unlimited_jids = module:get_option_inherited_set("unlimited_jids", {});
+
+if unlimited_jids:empty() then
+	return;
+end
+
+module:hook("authentication-success", function (event)
+	local session = event.session;
+	local jid = session.username .. "@" .. session.host;
+	if unlimited_jids:contains(jid) then
+		if session.conn and session.conn.setlimit then
+			session.conn:setlimit(0);
+		elseif session.throttle then
+			session.throttle = nil;
+		end
+	end
+end);