# HG changeset patch # User Matthew Wild # Date 1306538472 -3600 # Node ID cd4011af8b4c0699cf6972f42fef5b3072e1fa22 # Parent c249f10eb9bbe725b10fd3e31189730127708a49 mod_register: Move allow_registration option into an upvalue for efficiency (now it is being checked on every new c2s stream) diff -r c249f10eb9bb -r cd4011af8b4c plugins/mod_register.lua --- a/plugins/mod_register.lua Fri May 27 17:04:43 2011 +0100 +++ b/plugins/mod_register.lua Sat May 28 00:21:12 2011 +0100 @@ -19,6 +19,7 @@ local jid_bare = require "util.jid".bare; local compat = module:get_option_boolean("registration_compat", true); +local allow_registration = module:get_option_boolean("allow_registration", true); module:add_feature("jabber:iq:register"); @@ -27,7 +28,7 @@ local session, features = event.origin, event.features; -- Advertise registration to unauthorized clients only. - if module:get_option("allow_registration") == false or session.type ~= "c2s_unauthed" then + if not(allow_registration) or session.type ~= "c2s_unauthed" then return end @@ -126,7 +127,7 @@ module:hook("stanza/iq/jabber:iq:register:query", function(event) local session, stanza = event.origin, event.stanza; - if module:get_option("allow_registration") == false or session.type ~= "c2s_unauthed" then + if not(allow_registration) or session.type ~= "c2s_unauthed" then session.send(st.error_reply(stanza, "cancel", "service-unavailable")); else local query = stanza.tags[1];