Merge with trunk.

Thu, 19 Nov 2009 17:53:52 +0100

author
Tobias Markmann <tm@ayena.de>
date
Thu, 19 Nov 2009 17:53:52 +0100
changeset 2208
7cb6460b18d8
parent 2207
6094a4e2b6f3 (current diff)
parent 2088
5a9dc066a388 (diff)
child 2209
141896297cea

Merge with trunk.

util/sasl.lua file | annotate | diff | comparison | revisions
util/sasl/digest-md5.lua file | annotate | diff | comparison | revisions
--- a/net/dns.lua	Thu Nov 19 17:20:38 2009 +0100
+++ b/net/dns.lua	Thu Nov 19 17:53:52 2009 +0100
@@ -726,21 +726,21 @@
 			local packet = sock:receive();
 			if packet then
 				response = self:decode(packet);
-				if response then
+				if response and self.active[response.header.id] 
+					and self.active[response.header.id][response.question.raw] then
 					--print('received response');
 					--self.print(response);
 
-					for i,section in pairs({ 'answer', 'authority', 'additional' }) do
-						for j,rr in pairs(response[section]) do
+					for j,rr in pairs(response.answer) do
+						if rr.name:sub(-#response.question[1].name, -1) == response.question[1].name then
 							self:remember(rr, response.question[1].type)
 						end
 					end
 
 					-- retire the query
 					local queries = self.active[response.header.id];
-					if queries[response.question.raw] then
-						queries[response.question.raw] = nil;
-					end
+					queries[response.question.raw] = nil;
+					
 					if not next(queries) then self.active[response.header.id] = nil; end
 					if not next(self.active) then self:closeall(); end
 
--- a/plugins/mod_bosh.lua	Thu Nov 19 17:20:38 2009 +0100
+++ b/plugins/mod_bosh.lua	Thu Nov 19 17:53:52 2009 +0100
@@ -254,6 +254,7 @@
 		if stanza.attr.xmlns == xmlns_bosh then
 			stanza.attr.xmlns = "jabber:client";
 		end
+		session.ip = request.handler.ip();
 		core_process_stanza(session, stanza);
 	end
 end
--- a/plugins/mod_console.lua	Thu Nov 19 17:20:38 2009 +0100
+++ b/plugins/mod_console.lua	Thu Nov 19 17:53:52 2009 +0100
@@ -650,3 +650,5 @@
 	end
 end
 end
+
+prosody.net_activate_ports("console", "console", {5582}, "tcp");
--- a/plugins/mod_register.lua	Thu Nov 19 17:20:38 2009 +0100
+++ b/plugins/mod_register.lua	Thu Nov 19 17:53:52 2009 +0100
@@ -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
--- a/prosody	Thu Nov 19 17:20:38 2009 +0100
+++ b/prosody	Thu Nov 19 17:53:52 2009 +0100
@@ -153,6 +153,40 @@
 		prosody.events.fire_event("server-stopping", {reason = reason});
 		server.setquitting(true);
 	end
+
+	-- Load SSL settings from config, and create a ctx table
+	local global_ssl_ctx = rawget(_G, "ssl") and config.get("*", "core", "ssl");
+	if global_ssl_ctx then
+		local default_ssl_ctx = { mode = "server", protocol = "sslv23", capath = "/etc/ssl/certs", verify = "none"; };
+		setmetatable(global_ssl_ctx, { __index = default_ssl_ctx });
+	end
+
+	local cl = require "net.connlisteners";
+	function prosody.net_activate_ports(option, listener, default, conntype)
+		conntype = conntype or (global_ssl_ctx and "tls") or "tcp";
+		if not cl.get(listener) then return; end
+		local ports = config.get("*", "core", option.."_ports") or default;
+		if type(ports) == "number" then ports = {ports} end;
+		
+		if type(ports) ~= "table" then
+			log("error", "core."..option.." is not a table");
+		else
+			for _, port in ipairs(ports) do
+				if type(port) ~= "number" then
+					log("error", "Non-numeric "..option.."_ports: "..tostring(port));
+				else
+					cl.start(listener, { 
+						ssl = conntype ~= "tcp" and global_ssl_ctx,
+						port = port,
+						interface = config.get("*", "core", option.."_interface") 
+							or cl.get(listener).default_interface 
+							or config.get("*", "core", "interface"),
+						type = conntype
+					});
+				end
+			end
+		end
+	end
 end
 
 function read_version()
@@ -220,45 +254,11 @@
 	eventmanager.fire_event("server-starting");
 	prosody.events.fire_event("server-starting");
 
-	-- Load SSL settings from config, and create a ctx table
-	local global_ssl_ctx = rawget(_G, "ssl") and config.get("*", "core", "ssl");
-	if global_ssl_ctx then
-		local default_ssl_ctx = { mode = "server", protocol = "sslv23", capath = "/etc/ssl/certs", verify = "none"; };
-		setmetatable(global_ssl_ctx, { __index = default_ssl_ctx });
-	end
-
-	local cl = require "net.connlisteners";
 	-- start listening on sockets
-	function prosody.net_activate_ports(option, listener, default, conntype)
-		if not cl.get(listener) then return; end
-		local ports = config.get("*", "core", option.."_ports") or default;
-		if type(ports) == "number" then ports = {ports} end;
-		
-		if type(ports) ~= "table" then
-			log("error", "core."..option.." is not a table");
-		else
-			for _, port in ipairs(ports) do
-				if type(port) ~= "number" then
-					log("error", "Non-numeric "..option.."_ports: "..tostring(port));
-				else
-					cl.start(listener, { 
-						ssl = conntype ~= "tcp" and global_ssl_ctx,
-						port = port,
-						interface = config.get("*", "core", option.."_interface") 
-							or cl.get(listener).default_interface 
-							or config.get("*", "core", "interface"),
-						type = conntype
-					});
-				end
-			end
-		end
-	end
-
-	prosody.net_activate_ports("c2s", "xmppclient", {5222}, (global_ssl_ctx and "tls") or "tcp");
-	prosody.net_activate_ports("s2s", "xmppserver", {5269}, (global_ssl_ctx and "tls") or "tcp");
+	prosody.net_activate_ports("c2s", "xmppclient", {5222});
+	prosody.net_activate_ports("s2s", "xmppserver", {5269});
 	prosody.net_activate_ports("component", "xmppcomponent", {}, "tcp");
 	prosody.net_activate_ports("legacy_ssl", "xmppclient", {}, "ssl");
-	prosody.net_activate_ports("console", "console", {5582}, "tcp");
 
 	prosody.start_time = os.time();
 end	
--- a/util/sasl/digest-md5.lua	Thu Nov 19 17:20:38 2009 +0100
+++ b/util/sasl/digest-md5.lua	Thu Nov 19 17:53:52 2009 +0100
@@ -101,7 +101,8 @@
 	end
 	local function parse(data)
 		local message = {}
-		for k, v in s_gmatch(data, [[([%w%-]+)="?([^",]*)"?,?]]) do -- FIXME The hacky regex makes me shudder
+		-- COMPAT: %z in the pattern to work around jwchat bug (sends "charset=utf-8\0")
+		for k, v in gmatch(data, [[([%w%-]+)="?([^",%z]*)"?,?]]) do -- FIXME The hacky regex makes me shudder
 			message[k] = v;
 		end
 		return message;

mercurial