aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2012-07-28 01:14:31 +0100
committerMatthew Wild <mwild1@gmail.com>2012-07-28 01:14:31 +0100
commitfbe75768718891167313bc0cbcffcd3a46042d31 (patch)
tree2732225257e7b8ade28695dad7c0df3f7cea00b1 /core
parent8395775fc1bd1e72a8c83927003d2af1ed5f304a (diff)
parentf926338983c2f1dd0276d41e3c3d8e28cbef3d02 (diff)
downloadprosody-fbe75768718891167313bc0cbcffcd3a46042d31.tar.gz
prosody-fbe75768718891167313bc0cbcffcd3a46042d31.zip
Merge with Florob
Diffstat (limited to 'core')
-rw-r--r--core/certmanager.lua11
-rw-r--r--core/loggingmanager.lua10
-rw-r--r--core/moduleapi.lua4
-rw-r--r--core/portmanager.lua35
-rw-r--r--core/rostermanager.lua12
-rw-r--r--core/s2smanager.lua8
-rw-r--r--core/sessionmanager.lua15
-rw-r--r--core/stanza_router.lua12
-rw-r--r--core/usermanager.lua4
9 files changed, 58 insertions, 53 deletions
diff --git a/core/certmanager.lua b/core/certmanager.lua
index d524a07e..20a6d609 100644
--- a/core/certmanager.lua
+++ b/core/certmanager.lua
@@ -11,14 +11,17 @@ local log = require "util.logger".init("certmanager");
local ssl = ssl;
local ssl_newcontext = ssl and ssl.newcontext;
-local setmetatable, tostring = setmetatable, tostring;
+local tostring = tostring;
local prosody = prosody;
local resolve_path = configmanager.resolve_relative_path;
local config_path = prosody.paths.config;
-local luasec_major, luasec_minor = ssl._VERSION:match("^(%d+)%.(%d+)");
-local luasec_has_noticket = tonumber(luasec_major)>0 or tonumber(luasec_minor)>=4;
+local luasec_has_noticket;
+if ssl then
+ local luasec_major, luasec_minor = ssl._VERSION:match("^(%d+)%.(%d+)");
+ luasec_has_noticket = tonumber(luasec_major)>0 or tonumber(luasec_minor)>=4;
+end
module "certmanager"
@@ -78,7 +81,7 @@ function create_context(host, mode, user_ssl_config)
else
reason = "Reason: "..tostring(reason):lower();
end
- log("error", "SSL/TLS: Failed to load %s: %s (for %s)", file, reason, host);
+ log("error", "SSL/TLS: Failed to load '%s': %s (for %s)", file, reason, host);
else
log("error", "SSL/TLS: Error initialising for %s: %s", host, err);
end
diff --git a/core/loggingmanager.lua b/core/loggingmanager.lua
index 56a3ee2c..ce25b0e8 100644
--- a/core/loggingmanager.lua
+++ b/core/loggingmanager.lua
@@ -7,14 +7,12 @@
--
-local format, rep = string.format, string.rep;
-local pcall = pcall;
-local debug = debug;
-local tostring, setmetatable, rawset, pairs, ipairs, type =
- tostring, setmetatable, rawset, pairs, ipairs, type;
+local format = string.format;
+local setmetatable, rawset, pairs, ipairs, type =
+ setmetatable, rawset, pairs, ipairs, type;
local io_open, io_write = io.open, io.write;
local math_max, rep = math.max, string.rep;
-local os_date, os_getenv = os.date, os.getenv;
+local os_date = os.date;
local getstyle, setstyle = require "util.termcolours".getstyle, require "util.termcolours".setstyle;
if os.getenv("__FLUSH_LOG") then
diff --git a/core/moduleapi.lua b/core/moduleapi.lua
index 2bcf9b84..54077826 100644
--- a/core/moduleapi.lua
+++ b/core/moduleapi.lua
@@ -14,8 +14,6 @@ local logger = require "util.logger";
local pluginloader = require "util.pluginloader";
local timer = require "util.timer";
-local multitable_new = require "util.multitable".new;
-
local t_insert, t_remove, t_concat = table.insert, table.remove, table.concat;
local error, setmetatable, type = error, setmetatable, type;
local ipairs, pairs, select, unpack = ipairs, pairs, select, unpack;
@@ -338,4 +336,4 @@ function api:load_resource(path, mode)
return io.open(path, mode);
end
-return api;
+return api; \ No newline at end of file
diff --git a/core/portmanager.lua b/core/portmanager.lua
index b563fb10..3fcc8173 100644
--- a/core/portmanager.lua
+++ b/core/portmanager.lua
@@ -52,13 +52,6 @@ local function error_to_friendly_message(service_name, port, err)
end
elseif err:match("permission") then
friendly_message = "Prosody does not have sufficient privileges to use this port";
- elseif err == "no ssl context" then
- if not config.get("*", "core", "ssl") then
- friendly_message = "there is no 'ssl' config under Host \"*\" which is "
- .."require for legacy SSL ports";
- else
- friendly_message = "initializing SSL support failed, see previous log entries";
- end
end
return friendly_message;
end
@@ -110,22 +103,28 @@ function activate(service_name)
if #active_services:search(nil, interface, port) > 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>");
else
+ local err;
-- Create SSL context for this service/port
if service_info.encryption == "ssl" then
local ssl_config = config.get("*", config_prefix.."ssl");
- ssl = certmanager.create_context(service_info.name.." port "..port, "server", ssl_config and (ssl_config[port]
+ ssl, err = certmanager.create_context(service_info.name.." port "..port, "server", ssl_config and (ssl_config[port]
or (ssl_config.certificate and ssl_config)));
+ if not ssl then
+ log("error", "Error binding encrypted port for %s: %s", service_info.name, error_to_friendly_message(service_name, port, err) or "unknown error");
+ end
end
- -- Start listening on interface+port
- local handler, err = server.addserver(interface, port, listener, mode, ssl);
- if not handler then
- log("error", "Failed to open server port %d on %s, %s", port, interface, error_to_friendly_message(service_name, port, err));
- else
- log("debug", "Added listening service %s to [%s]:%d", service_name, interface, port);
- active_services:add(service_name, interface, port, {
- server = handler;
- service = service_info;
- });
+ if not err then
+ -- Start listening on interface+port
+ local handler, err = server.addserver(interface, port, listener, mode, ssl);
+ if not handler then
+ log("error", "Failed to open server port %d on %s, %s", port, interface, error_to_friendly_message(service_name, port, err));
+ else
+ log("debug", "Added listening service %s to [%s]:%d", service_name, interface, port);
+ active_services:add(service_name, interface, port, {
+ server = handler;
+ service = service_info;
+ });
+ end
end
end
end
diff --git a/core/rostermanager.lua b/core/rostermanager.lua
index 9d1ff5e2..ac4f4e3d 100644
--- a/core/rostermanager.lua
+++ b/core/rostermanager.lua
@@ -83,15 +83,15 @@ end
function load_roster(username, host)
local jid = username.."@"..host;
- log("debug", "load_roster: asked for: "..jid);
+ log("debug", "load_roster: asked for: %s", jid);
local user = bare_sessions[jid];
local roster;
if user then
roster = user.roster;
if roster then return roster; end
- log("debug", "load_roster: loading for new user: "..username.."@"..host);
+ log("debug", "load_roster: loading for new user: %s@%s", username, host);
else -- Attempt to load roster for non-loaded user
- log("debug", "load_roster: loading for offline user: "..username.."@"..host);
+ log("debug", "load_roster: loading for offline user: %s@%s", username, host);
end
local data, err = datamanager.load(username, host, "roster");
roster = data or {};
@@ -99,7 +99,7 @@ function load_roster(username, host)
if not roster[false] then roster[false] = { broken = err or nil }; end
if roster[jid] then
roster[jid] = nil;
- log("warn", "roster for "..jid.." has a self-contact");
+ log("warn", "roster for %s has a self-contact", jid);
end
if not err then
hosts[host].events.fire_event("roster-load", username, host, roster);
@@ -108,7 +108,7 @@ function load_roster(username, host)
end
function save_roster(username, host, roster)
- log("debug", "save_roster: saving roster for "..username.."@"..host);
+ log("debug", "save_roster: saving roster for %s@%s", username, host);
if not roster then
roster = hosts[host] and hosts[host].sessions[username] and hosts[host].sessions[username].roster;
--if not roster then
@@ -238,7 +238,7 @@ function set_contact_pending_out(username, host, jid) -- subscribe
roster[jid] = item;
end
item.ask = "subscribe";
- log("debug", "set_contact_pending_out: saving roster; set "..username.."@"..host..".roster["..jid.."].ask=subscribe");
+ log("debug", "set_contact_pending_out: saving roster; set %s@%s.roster[%q].ask=subscribe", username, host, jid);
return save_roster(username, host, roster);
end
function unsubscribe(username, host, jid)
diff --git a/core/s2smanager.lua b/core/s2smanager.lua
index 9e0a91d1..76dde9d2 100644
--- a/core/s2smanager.lua
+++ b/core/s2smanager.lua
@@ -74,7 +74,7 @@ function make_authenticated(session, host)
else
return false;
end
- session.log("debug", "connection %s->%s is now authenticated for %s", session.from_host or "(unknown)", session.to_host or "(unknown)", host);
+ session.log("debug", "connection %s->%s is now authenticated for %s", session.from_host, session.to_host, host);
mark_connected(session);
@@ -87,7 +87,7 @@ function mark_connected(session)
local from, to = session.from_host, session.to_host;
- session.log("info", session.direction.." s2s connection "..from.."->"..to.." complete");
+ session.log("info", "%s s2s connection %s->%s complete", session.direction, from, to);
local event_data = { session = session };
if session.type == "s2sout" then
@@ -105,7 +105,7 @@ function mark_connected(session)
if session.direction == "outgoing" then
if sendq then
- session.log("debug", "sending "..#sendq.." queued stanzas across new outgoing connection to "..session.to_host);
+ session.log("debug", "sending %d queued stanzas across new outgoing connection to %s", #sendq, session.to_host);
for i, data in ipairs(sendq) do
send(data[1]);
sendq[i] = nil;
@@ -133,7 +133,7 @@ local resting_session = { -- Resting, not dead
function retire_session(session, reason)
local log = session.log or log;
for k in pairs(session) do
- if k ~= "trace" and k ~= "log" and k ~= "id" then
+ if k ~= "trace" and k ~= "log" and k ~= "id" and k ~= "conn" then
session[k] = nil;
end
end
diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua
index 37c1626a..6945b8de 100644
--- a/core/sessionmanager.lua
+++ b/core/sessionmanager.lua
@@ -6,8 +6,8 @@
-- COPYING file in the source package for more information.
--
-local tonumber, tostring, setmetatable = tonumber, tostring, setmetatable;
-local ipairs, pairs, print, next= ipairs, pairs, print, next;
+local tostring, setmetatable = tostring, setmetatable;
+local pairs, next= pairs, next;
local hosts = hosts;
local full_sessions = full_sessions;
@@ -15,7 +15,6 @@ local bare_sessions = bare_sessions;
local logger = require "util.logger";
local log = logger.init("sessionmanager");
-local error = error;
local rm_load_roster = require "core.rostermanager".load_roster;
local config_get = require "core.configmanager".get;
local resourceprep = require "util.encodings".stringprep.resourceprep;
@@ -23,12 +22,8 @@ local nodeprep = require "util.encodings".stringprep.nodeprep;
local uuid_generate = require "util.uuid".generate;
local initialize_filters = require "util.filters".initialize;
-local fire_event = prosody.events.fire_event;
-local add_task = require "util.timer".add_task;
local gettime = require "socket".gettime;
-local st = require "util.stanza";
-
local newproxy = newproxy;
local getmetatable = getmetatable;
@@ -43,7 +38,7 @@ function new_session(conn)
getmetatable(session.trace).__gc = function () open_sessions = open_sessions - 1; end;
end
open_sessions = open_sessions + 1;
- log("debug", "open sessions now: ".. open_sessions);
+ log("debug", "open sessions now: %d", open_sessions);
local filter = initialize_filters(session);
local w = conn.write;
@@ -82,13 +77,13 @@ function retire_session(session)
end
end
- function session.send(data) log("debug", "Discarding data sent to resting session: %s", tostring(data)); end
+ function session.send(data) log("debug", "Discarding data sent to resting session: %s", tostring(data)); return false; end
function session.data(data) log("debug", "Discarding data received from resting session: %s", tostring(data)); end
return setmetatable(session, resting_session);
end
function destroy_session(session, err)
- (session.log or log)("info", "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
diff --git a/core/stanza_router.lua b/core/stanza_router.lua
index f01c0fee..94753678 100644
--- a/core/stanza_router.lua
+++ b/core/stanza_router.lua
@@ -17,6 +17,18 @@ local jid_prepped_split = require "util.jid".prepped_split;
local full_sessions = _G.prosody.full_sessions;
local bare_sessions = _G.prosody.bare_sessions;
+local core_post_stanza, core_process_stanza, core_route_stanza;
+
+function deprecated_warning(f)
+ _G[f] = function(...)
+ log("warn", "Using the global %s() is deprecated, use module:send() or prosody.%s(). %s", f, f, debug.traceback());
+ return prosody[f](...);
+ end
+end
+deprecated_warning"core_post_stanza";
+deprecated_warning"core_process_stanza";
+deprecated_warning"core_route_stanza";
+
local function handle_unhandled_stanza(host, origin, stanza)
local name, xmlns, origin_type = stanza.name, stanza.attr.xmlns or "jabber:client", origin.type;
if name == "iq" and xmlns == "jabber:client" then
diff --git a/core/usermanager.lua b/core/usermanager.lua
index 50aee701..3aba5786 100644
--- a/core/usermanager.lua
+++ b/core/usermanager.lua
@@ -91,8 +91,8 @@ function delete_user(username, host)
return hosts[host].users.delete_user(username);
end
-function get_sasl_handler(host)
- return hosts[host].users.get_sasl_handler();
+function get_sasl_handler(host, session)
+ return hosts[host].users.get_sasl_handler(session);
end
function get_provider(host)