Mercurial > prosody-modules
view mod_c2s_limit_sessions/mod_c2s_limit_sessions.lua @ 6562:5da6fb562df9 default tip
mod_unified_push: Fix push error handling (fixes #2000)
Use the error object that send_iq() passes
as an argument to it's reject callback instead of attempting
and failing to do the parsing in the callback itself.
| author | kmq |
|---|---|
| date | Mon, 06 Jul 2026 14:23:57 +0200 |
| parents | 668b1f0a4dc6 |
| children |
line wrap: on
line source
-- mod_c2s_limit_sessions local next, count = next, require "util.iterators".count; local max_resources = module:get_option_number("max_resources", 10); local sessions = prosody.hosts[module.host].sessions; module:hook("pre-resource-bind", function(event) local session = event.session; if not sessions[session.username] then return -- zero sessions end if count(next, sessions[session.username].sessions) >= max_resources then event.error = { condition = "policy-violation", text = "Too many active connections to this account" }; session:close(event.error); return false; end end, -1);
