Changeset

11734:c0fc4ca74046

mod_limits: Factor out function for disabling limits allowing use from shell Also enables reuse for s2s, which we will add next.
author Kim Alvefur <zash@zash.se>
date Thu, 29 Jul 2021 20:11:48 +0200
parents 11733:27699cc148df
children 11735:7d29167bfcc3
files plugins/mod_limits.lua
diffstat 1 files changed, 13 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_limits.lua	Thu Jul 29 20:04:57 2021 +0200
+++ b/plugins/mod_limits.lua	Thu Jul 29 20:11:48 2021 +0200
@@ -111,23 +111,27 @@
 	filters.remove_filter_hook(filter_hook);
 end
 
+function unlimited(session)
+	local session_type = session.type:match("^[^_]+");
+	if session.conn and session.conn.setlimit then
+		session.conn:setlimit(0);
+		-- Currently no burst support
+	else
+		local filter_set = type_filters[session_type];
+		filters.remove_filter(session, "bytes/in", filter_set.bytes_in);
+		session.throttle = nil;
+	end
+end
+
 function module.add_host(module)
 	local unlimited_jids = module:get_option_inherited_set("unlimited_jids", {});
 
 	if not unlimited_jids:empty() 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
-				if session.conn and session.conn.setlimit then
-					session.conn:setlimit(0);
-					-- Currently no burst support
-				else
-					local filter_set = type_filters[session_type];
-					filters.remove_filter(session, "bytes/in", filter_set.bytes_in);
-					session.throttle = nil;
-				end
+				unlimited(session);
 			end
 		end);
 	end