From 87fabe0fe7c65949f55b0b310fc80fd811029335 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sat, 28 May 2011 00:21:12 +0100 Subject: mod_register: Move allow_registration option into an upvalue for efficiency (now it is being checked on every new c2s stream) --- plugins/mod_register.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/mod_register.lua b/plugins/mod_register.lua index b4683b58..50d29da8 100644 --- a/plugins/mod_register.lua +++ b/plugins/mod_register.lua @@ -19,6 +19,7 @@ local nodeprep = require "util.encodings".stringprep.nodeprep; 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 @@ module:hook("stream-features", function(event) 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 @@ for _, ip in ipairs(blacklisted_ips) do blacklisted_ips[ip] = true; end 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]; -- cgit v1.2.3