Changeset

7950:f91e7ec9654e

Merge 0.10->trunk
author Kim Alvefur <zash@zash.se>
date Mon, 06 Mar 2017 01:14:32 +0100
parents 7946:c92102fe409b (current diff) 7949:8acc35b5355a (diff)
children 7957:083c062c2fb7
files core/moduleapi.lua core/s2smanager.lua core/sessionmanager.lua core/storagemanager.lua
diffstat 11 files changed, 42 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/.luacheckrc	Fri Mar 03 11:52:22 2017 +0100
+++ b/.luacheckrc	Mon Mar 06 01:14:32 2017 +0100
@@ -7,8 +7,11 @@
 codes = true
 ignore = { "411/err", "421/err", "411/ok", "421/ok", "211/_ENV" }
 
+max_line_length = 150
+
 files["core/"] = {
-	ignore = { "122/prosody", "122/hosts" };
+	read_globals = { "prosody", "hosts" };
+	globals = { "prosody.hosts.?", "hosts.?" };
 }
 files["plugins/"] = {
 	globals = { "module" };
--- a/core/configmanager.lua	Fri Mar 03 11:52:22 2017 +0100
+++ b/core/configmanager.lua	Mon Mar 06 01:14:32 2017 +0100
@@ -158,7 +158,8 @@
 
 		function env.Component(name)
 			name = nameprep(name);
-			if rawget(config_table, name) and rawget(config_table[name], "defined") and not rawget(config_table[name], "component_module") then
+			if rawget(config_table, name) and rawget(config_table[name], "defined")
+				and not rawget(config_table[name], "component_module") then
 				error(format("Component %q clashes with previously defined Host %q, for services use a sub-domain like conference.%s",
 					name, name, name), 0);
 			end
--- a/core/loggingmanager.lua	Fri Mar 03 11:52:22 2017 +0100
+++ b/core/loggingmanager.lua	Mon Mar 06 01:14:32 2017 +0100
@@ -5,7 +5,7 @@
 -- This project is MIT/X11 licensed. Please see the
 -- COPYING file in the source package for more information.
 --
-
+-- luacheck: globals log prosody.log
 
 local format = string.format;
 local setmetatable, rawset, pairs, ipairs, type =
--- a/core/moduleapi.lua	Fri Mar 03 11:52:22 2017 +0100
+++ b/core/moduleapi.lua	Mon Mar 06 01:14:32 2017 +0100
@@ -116,7 +116,8 @@
 		self:log("warn", "Error: Insufficient parameters to module:hook_stanza()");
 		return;
 	end
-	return self:hook("stanza/"..(xmlns and (xmlns..":") or "")..name, function (data) return handler(data.origin, data.stanza, data); end, priority);
+	return self:hook("stanza/"..(xmlns and (xmlns..":") or "")..name,
+		function (data) return handler(data.origin, data.stanza, data); end, priority);
 end
 api.hook_stanza = api.hook_tag; -- COMPAT w/pre-0.9
 
@@ -188,7 +189,8 @@
 		local path = paths[i];
 		if path:sub(1,1) ~= "/" then -- Prepend default components
 			local n_components = select(2, path:gsub("/", "%1"));
-			path = (n_components<#default_path_components and "/" or "")..t_concat(default_path_components, "/", 1, #default_path_components-n_components).."/"..path;
+			path = (n_components<#default_path_components and "/" or "")
+				..t_concat(default_path_components, "/", 1, #default_path_components-n_components).."/"..path;
 		end
 		local shared = shared_data[path];
 		if not shared then
--- a/core/modulemanager.lua	Fri Mar 03 11:52:22 2017 +0100
+++ b/core/modulemanager.lua	Mon Mar 06 01:14:32 2017 +0100
@@ -39,7 +39,8 @@
 
 local _ENV = nil;
 
-local load_modules_for_host, load, unload, reload, get_module, get_items, get_modules, is_loaded, module_has_method, call_module_method;
+local load_modules_for_host, load, unload, reload, get_module, get_items;
+local get_modules, is_loaded, module_has_method, call_module_method;
 
 -- [host] = { [module] = module_env }
 local modulemap = { ["*"] = {} };
--- a/core/portmanager.lua	Fri Mar 03 11:52:22 2017 +0100
+++ b/core/portmanager.lua	Mon Mar 06 01:14:32 2017 +0100
@@ -103,7 +103,8 @@
 			if not port_number then
 				log("error", "Invalid port number specified for service '%s': %s", service_info.name, tostring(port));
 			elseif #active_services:search(nil, interface, port_number) > 0 then
-				log("error", "Multiple services configured to listen on the same port ([%s]:%d): %s, %s", interface, port, active_services:search(nil, interface, port)[1][1].service.name or "<unnamed>", service_name or "<unnamed>");
+				log("error", "Multiple services configured to listen on the same port ([%s]:%d): %s, %s", interface, port,
+					active_services:search(nil, interface, port)[1][1].service.name or "<unnamed>", service_name or "<unnamed>");
 			else
 				local err;
 				-- Create SSL context for this service/port
@@ -118,14 +119,16 @@
 						global_ssl_config[interface],
 						global_ssl_config[port]);
 					if not ssl then
-						log("error", "Error binding encrypted port for %s: %s", service_info.name, error_to_friendly_message(service_name, port_number, err) or "unknown error");
+						log("error", "Error binding encrypted port for %s: %s", service_info.name,
+							error_to_friendly_message(service_name, port_number, err) or "unknown error");
 					end
 				end
 				if not err then
 					-- Start listening on interface+port
 					local handler, err = server.addserver(interface, port_number, listener, mode, ssl);
 					if not handler then
-						log("error", "Failed to open server port %d on %s, %s", port_number, interface, error_to_friendly_message(service_name, port_number, err));
+						log("error", "Failed to open server port %d on %s, %s", port_number, interface,
+							error_to_friendly_message(service_name, port_number, err));
 					else
 						table.insert(hooked_ports, "["..interface.."]:"..port_number);
 						log("debug", "Added listening service %s to [%s]:%d", service_name, interface, port_number);
@@ -138,7 +141,8 @@
 			end
 		end
 	end
-	log("info", "Activated service '%s' on %s", service_name, #hooked_ports == 0 and "no ports" or table.concat(hooked_ports, ", "));
+	log("info", "Activated service '%s' on %s", service_name,
+		#hooked_ports == 0 and "no ports" or table.concat(hooked_ports, ", "));
 	return true;
 end
 
--- a/core/rostermanager.lua	Fri Mar 03 11:52:22 2017 +0100
+++ b/core/rostermanager.lua	Mon Mar 06 01:14:32 2017 +0100
@@ -5,7 +5,7 @@
 -- This project is MIT/X11 licensed. Please see the
 -- COPYING file in the source package for more information.
 --
-
+-- luacheck: globals prosody.bare_sessions.?.roster
 
 
 
--- a/core/s2smanager.lua	Fri Mar 03 11:52:22 2017 +0100
+++ b/core/s2smanager.lua	Mon Mar 06 01:14:32 2017 +0100
@@ -71,7 +71,9 @@
 
 local function destroy_session(session, reason)
 	if session.destroyed then return; end
-	(session.log or log)("debug", "Destroying "..tostring(session.direction).." session "..tostring(session.from_host).."->"..tostring(session.to_host)..(reason and (": "..reason) or ""));
+	(session.log or log)("debug", "Destroying "..tostring(session.direction)
+		.." session "..tostring(session.from_host).."->"..tostring(session.to_host)
+		..(reason and (": "..reason) or ""));
 
 	if session.direction == "outgoing" then
 		hosts[session.from_host].s2sout[session.to_host] = nil;
--- a/core/sessionmanager.lua	Fri Mar 03 11:52:22 2017 +0100
+++ b/core/sessionmanager.lua	Mon Mar 06 01:14:32 2017 +0100
@@ -5,6 +5,7 @@
 -- This project is MIT/X11 licensed. Please see the
 -- COPYING file in the source package for more information.
 --
+-- luacheck: globals prosody.full_sessions prosody.bare_sessions
 
 local tostring, setmetatable = tostring, setmetatable;
 local pairs, next= pairs, next;
@@ -77,7 +78,10 @@
 end
 
 local function destroy_session(session, err)
-	(session.log or log)("debug", "Destroying session for %s (%s@%s)%s", session.full_jid or "(unknown)", session.username or "(unknown)", session.host or "(unknown)", err and (": "..err) or "");
+	(session.log or log)("debug", "Destroying session for %s (%s@%s)%s",
+		session.full_jid or "(unknown)", session.username or "(unknown)",
+		session.host or "(unknown)", err and (": "..err) or "");
+
 	if session.destroyed then return; end
 
 	-- Remove session/resource from user's session list
--- a/core/stanza_router.lua	Fri Mar 03 11:52:22 2017 +0100
+++ b/core/stanza_router.lua	Mon Mar 06 01:14:32 2017 +0100
@@ -38,7 +38,8 @@
 		if st_type == "error" or (name == "iq" and st_type == "result") then
 			if st_type == "error" then
 				local err_type, err_condition, err_message = stanza:get_error();
-				log("debug", "Discarding unhandled error %s (%s, %s) from %s: %s", name, err_type, err_condition or "unknown condition", origin_type, stanza:top_tag());
+				log("debug", "Discarding unhandled error %s (%s, %s) from %s: %s",
+					name, err_type, err_condition or "unknown condition", origin_type, stanza:top_tag());
 			else
 				log("debug", "Discarding %s from %s of type: %s", name, origin_type, st_type or '<nil>');
 			end
@@ -52,7 +53,8 @@
 			origin.send(st.error_reply(stanza, "cancel", "service-unavailable"));
 		end
 	else
-		log("warn", "Unhandled %s stream element or stanza: %s; xmlns=%s: %s", origin_type, name, xmlns, tostring(stanza)); -- we didn't handle it
+		log("warn", "Unhandled %s stream element or stanza: %s; xmlns=%s: %s",
+			origin_type, name, xmlns, tostring(stanza)); -- we didn't handle it
 		origin:close("unsupported-stanza-type");
 	end
 end
@@ -211,12 +213,14 @@
 		else
 			local xmlns = stanza.attr.xmlns;
 			stanza.attr.xmlns = nil;
-			local routed = host_session.events.fire_event("route/remote", { origin = origin, stanza = stanza, from_host = from_host, to_host = host });
+			local routed = host_session.events.fire_event("route/remote", {
+				origin = origin, stanza = stanza, from_host = from_host, to_host = host });
 			stanza.attr.xmlns = xmlns; -- reset
 			if not routed then
 				log("debug", "... no, just kidding.");
 				if stanza.attr.type == "error" or (stanza.name == "iq" and stanza.attr.type == "result") then return; end
-				core_route_stanza(host_session, st.error_reply(stanza, "cancel", "not-allowed", "Communication with remote domains is not enabled"));
+				core_route_stanza(host_session, st.error_reply(stanza, "cancel", "not-allowed",
+					"Communication with remote domains is not enabled"));
 			end
 		end
 	end
--- a/core/storagemanager.lua	Fri Mar 03 11:52:22 2017 +0100
+++ b/core/storagemanager.lua	Mon Mar 06 01:14:32 2017 +0100
@@ -72,7 +72,8 @@
 		end
 	end
 	if found_sql2 then
-		log("error", "The temporary 'sql2' storage module has now been renamed to 'sql', please update your config file: https://prosody.im/doc/modules/mod_storage_sql2");
+		log("error", "The temporary 'sql2' storage module has now been renamed to 'sql', "
+			.."please update your config file: https://prosody.im/doc/modules/mod_storage_sql2");
 	end
 	return storage_config;
 end
@@ -180,7 +181,8 @@
 				if driver.purge then
 					purged[driver_name] = driver:purge(user);
 				else
-					log("warn", "Storage driver %s does not support removing all user data, you may need to delete it manually", driver_name);
+					log("warn", "Storage driver %s does not support removing all user data, "
+						.."you may need to delete it manually", driver_name);
 				end
 			end
 		end