aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_limits.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-07-29 20:11:48 +0200
committerKim Alvefur <zash@zash.se>2021-07-29 20:11:48 +0200
commit5d73586b4f890014db1b0a782cfcb3037ffbb1c4 (patch)
tree9f2f50612d321786df91c3c8b62dc797b9e70ec3 /plugins/mod_limits.lua
parentc315a8520126c29bcd2120550123e50cb2802c27 (diff)
downloadprosody-5d73586b4f890014db1b0a782cfcb3037ffbb1c4.tar.gz
prosody-5d73586b4f890014db1b0a782cfcb3037ffbb1c4.zip
mod_limits: Factor out function for disabling limits allowing use from shell
Also enables reuse for s2s, which we will add next.
Diffstat (limited to 'plugins/mod_limits.lua')
-rw-r--r--plugins/mod_limits.lua22
1 files changed, 13 insertions, 9 deletions
diff --git a/plugins/mod_limits.lua b/plugins/mod_limits.lua
index 9fe62d05..9905dded 100644
--- a/plugins/mod_limits.lua
+++ b/plugins/mod_limits.lua
@@ -111,23 +111,27 @@ function module.unload()
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