Merge 0.9->trunk
authorMatthew Wild <mwild1@gmail.com>
Wed, 03 Apr 2013 13:53:21 +0100
changeset 5420 706053e3f9f5
parent 5400 dd91b72a3ba0 (current diff)
parent 5419 e28fca8faf62 (diff)
child 5431 19d537b5aacc
Merge 0.9->trunk
--- a/AUTHORS	Sun Mar 31 13:21:19 2013 +0100
+++ b/AUTHORS	Wed Apr 03 13:53:21 2013 +0100
@@ -1,4 +1,10 @@
-== Core development team ==
+
+The Prosody project is open to contributions (see HACKERS file), but is
+maintained daily by:
 
-Matthew Wild (matthew.wild AT heavy-horse.co.uk)
-Waqas Hussain (waqas20 AT gmail.com)
+  - Matthew Wild (mail: matthew [at] prosody.im)
+  - Waqas Hussain (mail: waqas [at] prosody.im)
+  - Kim Alvefur (mail: zash [at] prosody.im)
+
+You can reach us collectively by email: developers [at] prosody.im
+or in realtime in the Prosody chatroom: prosody@conference.prosody.im
--- a/DEPENDS	Sun Mar 31 13:21:19 2013 +0100
+++ b/DEPENDS	Wed Apr 03 13:53:21 2013 +0100
@@ -1,9 +1,11 @@
-The easiest way to install dependencies is using the luarocks tool.
+
+For full information on our dependencies, version requirements, and
+where to find them, see http://prosody.im/doc/depends
+
+If you have luarocks available on your platform, install the following:
 
-Rocks:
-luaexpat
-luasocket
-luafilesystem
+  - luaexpat
+  - luasocket
+  - luafilesystem
+  - luasec
 
-Non-rocks:
-LuaSec for SSL connections
--- a/INSTALL	Sun Mar 31 13:21:19 2013 +0100
+++ b/INSTALL	Wed Apr 03 13:53:21 2013 +0100
@@ -1,18 +1,18 @@
-(This file was created from 
-http://prosody.im/doc/installing_from_source on 2012-05-12)
+(This file was created from
+http://prosody.im/doc/installing_from_source on 2013-03-31)
 
-===== Building =====
+====== Installing from source ======
 ==== Dependencies ====
 There are a couple of libraries which Prosody needs installed before 
 you can build it. These are:
 
-  * lua5.1: The interpreter
+  * lua5.1: The Lua 5.1 interpreter
   * liblua5.1: Lua 5.1 library
   * libssl 0.9.8: OpenSSL
   * libidn11: GNU libidn library, version 1.1
 
-These can be installed on Debian/Ubuntu with the packages: 
-lua5.1 liblua5.1-dev libidn11-dev libssl-dev
+These can be installed on Debian/Ubuntu with the packages: lua5.1 
+liblua5.1-dev libidn11-dev libssl-dev
 
 On Mandriva try: urpmi lua liblua-devel libidn-devel libopenssl-devel
 
@@ -33,7 +33,8 @@
 
    ./configure --ostype=PRESET
 
-Where PRESET can currently be one of: debian, macosx or freebsd
+Where PRESET can currently be one of: 'debian', 'macosx' or (in 0.8 
+and later) 'freebsd'
 
 ==== make ====
 Once you have run configure successfully, then you can simply run:
--- a/TODO	Sun Mar 31 13:21:19 2013 +0100
+++ b/TODO	Wed Apr 03 13:53:21 2013 +0100
@@ -1,10 +1,5 @@
-== 0.9 ==
-- IPv6
-- SASL EXTERNAL
+== 1.0 ==
 - Roster providers
-- Web interface
-
-== 1.0 ==
 - Statistics
 - Clustering
 - World domination
--- a/configure	Sun Mar 31 13:21:19 2013 +0100
+++ b/configure	Wed Apr 03 13:53:21 2013 +0100
@@ -95,6 +95,7 @@
       if [ "$OSTYPE" = "debian" ]
       then LUA_SUFFIX="5.1";
 	LUA_SUFFIX_SET=yes
+	RUNWITH="lua5.1"
 	LUA_INCDIR=/usr/include/lua5.1;
 	LUA_INCDIR_SET=yes
 	CFLAGS="$CFLAGS -D_GNU_SOURCE"
--- a/core/configmanager.lua	Sun Mar 31 13:21:19 2013 +0100
+++ b/core/configmanager.lua	Wed Apr 03 13:53:21 2013 +0100
@@ -7,8 +7,8 @@
 --
 
 local _G = _G;
-local setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type, pairs, table =
-      setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type, pairs, table;
+local setmetatable, rawget, rawset, io, error, dofile, type, pairs, table =
+      setmetatable, rawget, rawset, io, error, dofile, type, pairs, table;
 local format, math_max = string.format, math.max;
 
 local fire_event = prosody and prosody.events.fire_event or function () end;
@@ -68,7 +68,6 @@
 
 -- Helper function to resolve relative paths (needed by config)
 do
-	local rel_path_start = ".."..path_sep;
 	function resolve_relative_path(parent_path, path)
 		if path then
 			-- Some normalization
@@ -152,7 +151,7 @@
 -- Built-in Lua parser
 do
 	local pcall, setmetatable = _G.pcall, _G.setmetatable;
-	local rawget, tostring = _G.rawget, _G.tostring;
+	local rawget = _G.rawget;
 	parsers.lua = {};
 	function parsers.lua.load(data, config_file, config)
 		local env;
@@ -213,7 +212,7 @@
 		end
 		env.component = env.Component;
 		
-		function env.Include(file, wildcard)
+		function env.Include(file)
 			if file:match("[*?]") then
 				local path_pos, glob = file:match("()([^"..path_sep.."]+)$");
 				local path = file:sub(1, math_max(path_pos-2,0));
--- a/core/moduleapi.lua	Sun Mar 31 13:21:19 2013 +0100
+++ b/core/moduleapi.lua	Wed Apr 03 13:53:21 2013 +0100
@@ -62,6 +62,20 @@
 function api:add_extension(data)
 	self:add_item("extension", data);
 end
+function api:has_feature(xmlns)
+	for _, feature in ipairs(self:get_host_items("feature")) do
+		if feature == xmlns then return true; end
+	end
+	return false;
+end
+function api:has_identity(category, type, name)
+	for _, id in ipairs(self:get_host_items("identity")) do
+		if id.category == category and id.type == type and id.name == name then
+			return true; 
+		end
+	end
+	return false;
+end
 
 function api:fire_event(...)
 	return (hosts[self.host] or prosody).events.fire_event(...);
@@ -271,23 +285,7 @@
 end
 
 function api:get_host_items(key)
-	local result = {};
-	for mod_name, module in pairs(modulemanager.get_modules(self.host)) do
-		module = module.module;
-		if module.items then
-			for _, item in ipairs(module.items[key] or NULL) do
-				t_insert(result, item);
-			end
-		end
-	end
-	for mod_name, module in pairs(modulemanager.get_modules("*")) do
-		module = module.module;
-		if module.items then
-			for _, item in ipairs(module.items[key] or NULL) do
-				t_insert(result, item);
-			end
-		end
-	end
+	local result = modulemanager.get_items(key, self.host) or {};
 	return result;
 end
 
--- a/core/modulemanager.lua	Sun Mar 31 13:21:19 2013 +0100
+++ b/core/modulemanager.lua	Wed Apr 03 13:53:21 2013 +0100
@@ -19,7 +19,7 @@
 
 local pcall, xpcall = pcall, xpcall;
 local setmetatable, rawget = setmetatable, rawget;
-local pairs, type, tostring = pairs, type, tostring;
+local ipairs, pairs, type, tostring, t_insert = ipairs, pairs, type, tostring, table.insert;
 
 local debug_traceback = debug.traceback;
 local unpack, select = unpack, select;
@@ -278,6 +278,23 @@
 	return modulemap[host] and modulemap[host][name];
 end
 
+function get_items(key, host)
+	local result = {};
+	local modules = modulemap[host];
+	if not key or not host or not modules then return nil; end
+
+	for _, module in pairs(modules) do
+		local mod = module.module;
+		if mod.items and mod.items[key] then
+			for _, value in ipairs(mod.items[key]) do
+				t_insert(result, value);
+			end
+		end
+	end
+
+	return result;
+end
+
 function get_modules(host)
 	return modulemap[host];
 end
--- a/net/http/server.lua	Sun Mar 31 13:21:19 2013 +0100
+++ b/net/http/server.lua	Wed Apr 03 13:53:21 2013 +0100
@@ -219,7 +219,13 @@
 				body = result;
 			elseif result_type == "table" then
 				for k, v in pairs(result) do
-					response[k] = v;
+					if k ~= "headers" then
+						response[k] = v;
+					else
+						for header_name, header_value in pairs(v) do
+							response.headers[header_name] = header_value;
+						end
+					end
 				end
 			end
 			response:send(body);
--- a/plugins/mod_groups.lua	Sun Mar 31 13:21:19 2013 +0100
+++ b/plugins/mod_groups.lua	Wed Apr 03 13:53:21 2013 +0100
@@ -13,7 +13,7 @@
 local groups_file;
 
 local jid, datamanager = require "util.jid", require "util.datamanager";
-local jid_bare, jid_prep = jid.bare, jid.prep;
+local jid_prep = jid.prep;
 
 local module_host = module:get_host();
 
@@ -121,3 +121,8 @@
 function module.unload()
 	datamanager.remove_callback(remove_virtual_contacts);
 end
+
+-- Public for other modules to access
+function group_contains(group_name, jid)
+	return groups[group_name][jid];
+end
--- a/plugins/mod_presence.lua	Sun Mar 31 13:21:19 2013 +0100
+++ b/plugins/mod_presence.lua	Wed Apr 03 13:53:21 2013 +0100
@@ -9,7 +9,7 @@
 local log = module._log;
 
 local require = require;
-local pairs, ipairs = pairs, ipairs;
+local pairs = pairs;
 local t_concat, t_insert = table.concat, table.insert;
 local s_find = string.find;
 local tonumber = tonumber;
@@ -346,7 +346,7 @@
 end);
 module:hook("presence/host", function(data)
 	-- inbound presence to the host
-	local origin, stanza = data.origin, data.stanza;
+	local stanza = data.stanza;
 	
 	local from_bare = jid_bare(stanza.attr.from);
 	local t = stanza.attr.type;
--- a/plugins/mod_pubsub.lua	Sun Mar 31 13:21:19 2013 +0100
+++ b/plugins/mod_pubsub.lua	Wed Apr 03 13:53:21 2013 +0100
@@ -164,16 +164,6 @@
 		reply = pubsub_error_reply(stanza, ret);
 	end
 	origin.send(reply);
-	if ok then
-		-- Send all current items
-		local ok, items = service:get_items(node, stanza.attr.from);
-		if items then
-			local jids = { [jid] = options or true };
-			for id, item in pairs(items) do
-				service.config.broadcaster("items", node, jids, item);
-			end
-		end
-	end
 end
 
 function handlers.set_unsubscribe(origin, stanza, unsubscribe)
--- a/plugins/mod_s2s/mod_s2s.lua	Sun Mar 31 13:21:19 2013 +0100
+++ b/plugins/mod_s2s/mod_s2s.lua	Wed Apr 03 13:53:21 2013 +0100
@@ -632,7 +632,11 @@
 	
 	if must_secure and not session.cert_identity_status then
 		module:log("warn", "Forbidding insecure connection to/from %s", host);
-		session:close(false);
+		if session.direction == "incoming" then
+			session:close({ condition = "not-authorized", text = "Your server's certificate is invalid, expired, or not trusted by"..session.to_host });
+		else -- Close outgoing connections without warning
+			session:close(false);
+		end
 		return false;
 	end
 end
--- a/prosody.cfg.lua.dist	Sun Mar 31 13:21:19 2013 +0100
+++ b/prosody.cfg.lua.dist	Wed Apr 03 13:53:21 2013 +0100
@@ -41,6 +41,8 @@
 	-- Not essential, but recommended
 		"private"; -- Private XML storage (for room bookmarks, etc.)
 		"vcard"; -- Allow users to set vCards
+	
+	-- These are commented by default as they have a performance impact
 		--"privacy"; -- Support privacy lists
 		--"compression"; -- Stream compression
 
@@ -51,7 +53,6 @@
 		"ping"; -- Replies to XMPP pings with pongs
 		"pep"; -- Enables users to publish their mood, activity, playing music and more
 		"register"; -- Allow users to register on this server using a client and change passwords
-		"adhoc"; -- Support for "ad-hoc commands" that can be executed with an XMPP client
 
 	-- Admin interfaces
 		"admin_adhoc"; -- Allows administration via an XMPP client that supports ad-hoc commands
@@ -71,14 +72,12 @@
 		--"legacyauth"; -- Legacy authentication. Only used by some old clients and bots.
 };
 
--- These modules are auto-loaded, should you
--- (for some mad reason) want to disable
--- them then uncomment them below
+-- These modules are auto-loaded, but should you want
+-- to disable them then uncomment them here:
 modules_disabled = {
-	-- "presence"; -- Route user/contact status information
-	-- "message"; -- Route messages
-	-- "iq"; -- Route info queries
 	-- "offline"; -- Store offline messages
+	-- "c2s"; -- Handle client connections
+	-- "s2s"; -- Handle server-to-server connections
 };
 
 -- Disable account creation by default, for security
@@ -92,14 +91,28 @@
 	certificate = "certs/localhost.crt";
 }
 
--- Only allow encrypted streams? Encryption is already used when
--- available. These options will cause Prosody to deny connections that
--- are not encrypted. Note that some servers do not support s2s
--- encryption or have it disabled, including gmail.com and Google Apps
--- domains.
+-- Force clients to use encrypted connections? This option will
+-- prevent clients from authenticating unless they are using encryption.
+
+c2s_require_encryption = false
+
+-- Force certificate authentication for server-to-server connections?
+-- This provides ideal security, but requires servers you communicate
+-- with to support encryption AND present valid, trusted certificates.
+-- For more information see http://prosody.im/doc/s2s#security
 
---c2s_require_encryption = false
---s2s_require_encryption = false
+s2s_secure = true
+
+-- Many servers don't support encryption or have invalid or self-signed
+-- certificates. You can list domains here that will not be required to
+-- authenticate using certificates. They will be authenticated using DNS.
+
+-- s2s_insecure_domains = { "gmail.com" }
+
+-- Even if you leave s2s_secure disabled, you can still require it for
+-- some domains by specifying a list here.
+
+-- s2s_secure_domains = { "jabber.org" }
 
 -- Select the authentication backend to use. The 'internal' providers
 -- use Prosody's configured data storage to store the authentication data.
--- a/tools/migration/Makefile	Sun Mar 31 13:21:19 2013 +0100
+++ b/tools/migration/Makefile	Wed Apr 03 13:53:21 2013 +0100
@@ -29,7 +29,8 @@
 	rm -f migrator.cfg.lua.install
 
 prosody-migrator.install: prosody-migrator.lua
-	sed "s|^CFG_SOURCEDIR=.*;$$|CFG_SOURCEDIR='$(INSTALLEDSOURCE)';|; \
+	sed "1s/\blua\b/$(RUNWITH)/; \
+		s|^CFG_SOURCEDIR=.*;$$|CFG_SOURCEDIR='$(INSTALLEDSOURCE)';|; \
 		s|^CFG_CONFIGDIR=.*;$$|CFG_CONFIGDIR='$(INSTALLEDCONFIG)';|;" \
 			< prosody-migrator.lua > prosody-migrator.install
 
--- a/util/helpers.lua	Sun Mar 31 13:21:19 2013 +0100
+++ b/util/helpers.lua	Wed Apr 03 13:53:21 2013 +0100
@@ -14,6 +14,14 @@
 
 local log = require "util.logger".init("util.debug");
 
+function log_host_events(host)
+	return log_events(prosody.hosts[host].events, host);
+end
+
+function revert_log_host_events(host)
+	return revert_log_events(prosody.hosts[host].events);
+end
+
 function log_events(events, name, logger)
 	local f = events.fire_event;
 	if not f then
--- a/util/stanza.lua	Sun Mar 31 13:21:19 2013 +0100
+++ b/util/stanza.lua	Wed Apr 03 13:53:21 2013 +0100
@@ -153,7 +153,7 @@
 	local n_children, n_tags = #self, #tags;
 	
 	local i = 1;
-	while curr_tag <= n_tags do
+	while curr_tag <= n_tags and n_tags > 0 do
 		if self[i] == tags[curr_tag] then
 			local ret = callback(self[i]);
 			if ret == nil then
@@ -161,13 +161,15 @@
 				t_remove(tags, curr_tag);
 				n_children = n_children - 1;
 				n_tags = n_tags - 1;
+				i = i - 1;
+				curr_tag = curr_tag - 1;
 			else
 				self[i] = ret;
 				tags[i] = ret;
 			end
-			i = i + 1;
 			curr_tag = curr_tag + 1;
 		end
+		i = i + 1;
 	end
 	return self;
 end