Software /
code /
prosody-modules
Changeset
1036:a44e755f7579
mod_muc_limits: Add muc_max_nick_length option, defaulting to 23 (bytes)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 01 Jun 2013 23:02:40 +0100 |
parents | 1035:09a5082a8162 |
children | 1037:892272432703 |
files | mod_muc_limits/mod_muc_limits.lua |
diffstat | 1 files changed, 7 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_muc_limits/mod_muc_limits.lua Sat Jun 01 22:47:55 2013 +0100 +++ b/mod_muc_limits/mod_muc_limits.lua Sat Jun 01 23:02:40 2013 +0100 @@ -8,6 +8,8 @@ local period = math.max(module:get_option_number("muc_event_rate", 0.5), 0); local burst = math.max(module:get_option_number("muc_burst_factor", 6), 1); +local max_nick_length = module:get_option_number("muc_max_nick_length", 23); -- Default chosen through scientific methods + local function handle_stanza(event) local origin, stanza = event.origin, event.stanza; if stanza.name == "presence" and stanza.attr.type == "unavailable" then -- Don't limit room leaving @@ -21,6 +23,11 @@ if occupant and occupant.affiliation then module:log("debug", "Skipping stanza from affiliated user..."); return; + elseif max_nick_length and stanza.name == "presence" and not room._occupants[stanza.attr.to] and #dest_nick > max_nick_length then + module:log("debug", "Forbidding long (%d bytes) nick in %s", #dest_nick, dest_room) + origin.send(st.error_reply(stanza, "modify", "policy-violation", "Your nick name is too long, please use a shorter one") + :up():tag("x", { xmlns = xmlns_muc })); + return true; end local throttle = room.throttle; if not room.throttle then