mod_register: Log a debug message when a session's IP is not available.

Wed, 18 Nov 2009 06:23:41 +0500

author
Waqas Hussain <waqas20@gmail.com>
date
Wed, 18 Nov 2009 06:23:41 +0500
changeset 2085
64872e216e23
parent 2084
ded03b7b040e
child 2086
911251f00f32

mod_register: Log a debug message when a session's IP is not available.

plugins/mod_register.lua file | annotate | diff | comparison | revisions
--- a/plugins/mod_register.lua	Wed Nov 18 06:22:52 2009 +0500
+++ b/plugins/mod_register.lua	Wed Nov 18 06:23:41 2009 +0500
@@ -117,7 +117,9 @@
 				local password = query:child_with_name("password");
 				if username and password then
 					-- Check that the user is not blacklisted or registering too often
-					if blacklisted_ips[session.ip] or (whitelist_only and not whitelisted_ips[session.ip]) then
+					if not session.ip then
+						module:log("debug", "User's IP not known; can't apply blacklist/whitelist");
+					elseif blacklisted_ips[session.ip] or (whitelist_only and not whitelisted_ips[session.ip]) then
 						session.send(st.error_reply(stanza, "cancel", "not-acceptable", "You are not allowed to register an account."));
 						return;
 					elseif min_seconds_between_registrations and not whitelisted_ips[session.ip] then

mercurial