Changeset

9942:b0d5f4ae92b7

mod_limits: Allow configuring a list of unrestricted JIDs (fixes #1323)
author Kim Alvefur <zash@zash.se>
date Tue, 02 Apr 2019 20:38:51 +0200
parents 9941:a2f8d54dd445
children 9943:46773fe2be45
files plugins/mod_limits.lua
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_limits.lua	Tue Apr 02 21:17:28 2019 +0200
+++ b/plugins/mod_limits.lua	Tue Apr 02 20:38:51 2019 +0200
@@ -96,3 +96,20 @@
 function module.unload()
 	filters.remove_filter_hook(filter_hook);
 end
+
+function module.add_host(module)
+	local unlimited_jids = module:get_option_inherited_set("unlimited_jids", {});
+
+	if not unlimited_jids:empy() then
+		module:hook("authentication-success", function (event)
+			local session = event.session;
+			local session_type = session.type:match("^[^_]+");
+			local jid = session.username .. "@" .. session.host;
+			if unlimited_jids:contains(jid) then
+				local filter_set = type_filters[session_type];
+				filters.remove_filter(session, "bytes/in", filter_set.bytes_in);
+				session.throttle = nil;
+			end
+		end);
+	end
+end