aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-07-28 19:17:09 +0100
committerMatthew Wild <mwild1@gmail.com>2009-07-28 19:17:09 +0100
commit5dfe9cf891dc5becd805dfbad79653d9eb840001 (patch)
treef64c675fbbac1f4acbcc959d820ddba16fd57a06
parent39e1b4b1df2c49739e89b80f4b4351a4e6b20f81 (diff)
parent8ad65c2824d2ee3bd52175df34fdd7bd9d393231 (diff)
downloadprosody-5dfe9cf891dc5becd805dfbad79653d9eb840001.tar.gz
prosody-5dfe9cf891dc5becd805dfbad79653d9eb840001.zip
Merge with 0.5
-rw-r--r--core/configmanager.lua1
-rw-r--r--core/hostmanager.lua5
-rw-r--r--core/loggingmanager.lua2
-rw-r--r--net/server.lua33
-rw-r--r--net/xmppclient_listener.lua5
-rw-r--r--net/xmppcomponent_listener.lua5
-rw-r--r--net/xmppserver_listener.lua5
-rw-r--r--plugins/mod_console.lua45
8 files changed, 94 insertions, 7 deletions
diff --git a/core/configmanager.lua b/core/configmanager.lua
index 7fc6aa13..b7ee605f 100644
--- a/core/configmanager.lua
+++ b/core/configmanager.lua
@@ -113,6 +113,7 @@ do
set(env.__currenthost or "*", "core", k, v);
end});
+ rawset(env, "__currenthost", "*") -- Default is global
function env.Host(name)
rawset(env, "__currenthost", name);
-- Needs at least one setting to logically exist :)
diff --git a/core/hostmanager.lua b/core/hostmanager.lua
index c7b975d1..ba363273 100644
--- a/core/hostmanager.lua
+++ b/core/hostmanager.lua
@@ -41,6 +41,11 @@ function activate(host, host_config)
or (configmanager.get(host, "core", "anonymous_login")
and (configmanager.get(host, "core", "disallow_s2s") ~= false))
};
+ for option_name in pairs(host_config.core) do
+ if option_name:match("_ports$") then
+ log("warn", "%s: Option '%s' has no effect for virtual hosts - put it in global Host \"*\" instead", host, option_name);
+ end
+ end
log((hosts_loaded_once and "info") or "debug", "Activated host: %s", host);
eventmanager.fire_event("host-activated", host, host_config);
end
diff --git a/core/loggingmanager.lua b/core/loggingmanager.lua
index 1d2f8d7d..d701511e 100644
--- a/core/loggingmanager.lua
+++ b/core/loggingmanager.lua
@@ -222,7 +222,7 @@ function log_sink_types.file(config)
local timestamps = config.timestamps;
- if timestamps == true then
+ if timestamps == nil or timestamps == true then
timestamps = default_timestamp; -- Default format
end
diff --git a/net/server.lua b/net/server.lua
index 6fe72712..966006c1 100644
--- a/net/server.lua
+++ b/net/server.lua
@@ -181,20 +181,41 @@ wrapserver = function( listeners, socket, ip, serverport, pattern, sslctx, maxco
out_error "server.lua: wrong server sslctx"
ssl = false
end
- sslctx, err = ssl_newcontext( sslctx )
- if not sslctx then
+ local ctx;
+ ctx, err = ssl_newcontext( sslctx )
+ if not ctx then
err = err or "wrong sslctx parameters"
- out_error( "server.lua: ", err )
+ local file;
+ file = err:match("^error loading (.-) %(");
+ if file then
+ if file == "private key" then
+ file = sslctx.key or "your private key";
+ elseif file == "certificate" then
+ file = sslctx.certificate or "your certificate file";
+ end
+ local reason = err:match("%((.+)%)$") or "some reason";
+ if reason == "Permission denied" then
+ reason = "Check that the permissions allow Prosody to read this file.";
+ elseif reason == "No such file or directory" then
+ reason = "Check that the path is correct, and the file exists.";
+ elseif reason == "system lib" then
+ reason = "Previous error (see logs), or other system error.";
+ else
+ reason = "Reason: "..tostring(reason or "unknown"):lower();
+ end
+ log("error", "SSL/TLS: Failed to load %s: %s", file, reason);
+ else
+ log("error", "SSL/TLS: Error initialising for port %d: %s", serverport, err );
+ end
ssl = false
end
+ sslctx = ctx;
end
if not ssl then
sslctx = false;
if startssl then
- out_error( "server.lua: Cannot start ssl on port: ", serverport )
+ log("error", "Failed to listen on port %d due to SSL/TLS to SSL/TLS initialisation errors (see logs)", serverport )
return nil, "Cannot start ssl, see log for details"
- else
- out_put("server.lua: ", "ssl not enabled on ", serverport);
end
end
diff --git a/net/xmppclient_listener.lua b/net/xmppclient_listener.lua
index e882546f..dcc561f3 100644
--- a/net/xmppclient_listener.lua
+++ b/net/xmppclient_listener.lua
@@ -70,9 +70,14 @@ end
local stream_xmlns_attr = {xmlns='urn:ietf:params:xml:ns:xmpp-streams'};
+local default_stream_attr = { ["xmlns:stream"] = stream_callbacks.stream_tag:gsub("%|[^|]+$", ""), xmlns = stream_callbacks.default_ns, version = "1.0", id = "" };
local function session_close(session, reason)
local log = session.log or log;
if session.conn then
+ if session.notopen then
+ session.send("<?xml version='1.0'?>");
+ session.send(st.stanza("stream:stream", default_stream_attr):top_tag());
+ end
if reason then
if type(reason) == "string" then -- assume stream error
log("info", "Disconnecting client, <stream:error> is: %s", reason);
diff --git a/net/xmppcomponent_listener.lua b/net/xmppcomponent_listener.lua
index e62bb810..36d74579 100644
--- a/net/xmppcomponent_listener.lua
+++ b/net/xmppcomponent_listener.lua
@@ -87,9 +87,14 @@ end
--- Closing a component connection
local stream_xmlns_attr = {xmlns='urn:ietf:params:xml:ns:xmpp-streams'};
+local default_stream_attr = { ["xmlns:stream"] = stream_callbacks.stream_tag:gsub("%|[^|]+$", ""), xmlns = stream_callbacks.default_ns, version = "1.0", id = "" };
local function session_close(session, reason)
local log = session.log or log;
if session.conn then
+ if session.notopen then
+ session.send("<?xml version='1.0'?>");
+ session.send(st.stanza("stream:stream", default_stream_attr):top_tag());
+ end
if reason then
if type(reason) == "string" then -- assume stream error
log("info", "Disconnecting component, <stream:error> is: %s", reason);
diff --git a/net/xmppserver_listener.lua b/net/xmppserver_listener.lua
index 2e70145d..1f27d841 100644
--- a/net/xmppserver_listener.lua
+++ b/net/xmppserver_listener.lua
@@ -70,9 +70,14 @@ end
local stream_xmlns_attr = {xmlns='urn:ietf:params:xml:ns:xmpp-streams'};
+local default_stream_attr = { ["xmlns:stream"] = stream_callbacks.stream_tag:gsub("%|[^|]+$", ""), xmlns = stream_callbacks.default_ns, version = "1.0", id = "" };
local function session_close(session, reason)
local log = session.log or log;
if session.conn then
+ if session.notopen then
+ session.sends2s("<?xml version='1.0'?>");
+ session.sends2s(st.stanza("stream:stream", default_stream_attr):top_tag());
+ end
if reason then
if type(reason) == "string" then -- assume stream error
log("info", "Disconnecting %s[%s], <stream:error> is: %s", session.host or "(unknown host)", session.type, reason);
diff --git a/plugins/mod_console.lua b/plugins/mod_console.lua
index 8b881c98..3a18ec0e 100644
--- a/plugins/mod_console.lua
+++ b/plugins/mod_console.lua
@@ -156,6 +156,51 @@ commands["!"] = function (session, data)
session.print("Sorry, not sure what you want");
end
+function commands.help(session, data)
+ local print = session.print;
+ local section = data:match("^help (%w+)");
+ if not section then
+ print [[Commands are divided into multiple sections. For help on a particular section, ]]
+ print [[type: help SECTION (for example, 'help c2s'). Sections are: ]]
+ print [[]]
+ print [[c2s - Commands to manage local client-to-server sessions]]
+ print [[s2s - Commands to manage sessions between this server and others]]
+ print [[module - Commands to load/reload/unload modules/plugins]]
+ print [[server - Uptime, version, shutting down, etc.]]
+ print [[console - Help regarding the console itself]]
+ elseif section == "c2s" then
+ print [[c2s:show(jid) - Show all client sessions with the specified JID (or all if no JID given)]]
+ print [[c2s:show_insecure() - Show all unencrypted client connections]]
+ print [[c2s:show_secure() - Show all encrypted client connections]]
+ print [[c2s:close(jid) - Close all sessions for the specified JID]]
+ elseif section == "s2s" then
+ print [[s2s:show(domain) - Show all s2s connections for the given domain (or all if no domain given)]]
+ print [[s2s:close(from, to) - Close a connection from one domain to another]]
+ elseif section == "module" then
+ print [[module:load(module, host) - Load the specified module on the specified host (or all hosts if none given)]]
+ print [[module:reload(module, host) - The same, but unloads and loads the module (saving state if the module supports it)]]
+ print [[module:unload(module, host) - The same, but just unloads the module from memory]]
+ elseif section == "server" then
+ print [[server:version() - Show the server's version number]]
+ print [[server:uptime() - Show how long the server has been running]]
+ --print [[server:shutdown(reason) - Shut down the server, with an optional reason to be broadcast to all connections]]
+ elseif section == "console" then
+ print [[Hey! Welcome to Prosody's admin console.]]
+ print [[First thing, if you're ever wondering how to get out, simply type 'quit'.]]
+ print [[Secondly, note that we don't support the full telnet protocol yet (it's coming)]]
+ print [[so you may have trouble using the arrow keys, etc. depending on your system.]]
+ print [[]]
+ print [[For now we offer a couple of handy shortcuts:]]
+ print [[!! - Repeat the last command]]
+ print [[!old!new! - repeat the last command, but with 'old' replaced by 'new']]
+ print [[]]
+ print [[For those well-versed in Prosody's internals, or taking instruction from those who are,]]
+ print [[you can prefix a command with > to escape the console sandbox, and access everything in]]
+ print [[the running server. Great fun, but be careful not to break anything :)]]
+ end
+ print [[]]
+end
+
-- Session environment --
-- Anything in def_env will be accessible within the session as a global variable