Software /
code /
prosody
Changeset
1618:ba2a92230b77
Merge with 0.5
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 28 Jul 2009 19:17:09 +0100 |
parents | 1611:e20f90743863 (current diff) 1617:c6e175a0d83b (diff) |
children | 1622:1ca7a247d04f |
files | net/xmppclient_listener.lua net/xmppserver_listener.lua plugins/mod_console.lua |
diffstat | 8 files changed, 94 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/core/configmanager.lua Tue Jul 28 05:33:51 2009 +0500 +++ b/core/configmanager.lua Tue Jul 28 19:17:09 2009 +0100 @@ -113,6 +113,7 @@ 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 :)
--- a/core/hostmanager.lua Tue Jul 28 05:33:51 2009 +0500 +++ b/core/hostmanager.lua Tue Jul 28 19:17:09 2009 +0100 @@ -41,6 +41,11 @@ 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
--- a/core/loggingmanager.lua Tue Jul 28 05:33:51 2009 +0500 +++ b/core/loggingmanager.lua Tue Jul 28 19:17:09 2009 +0100 @@ -222,7 +222,7 @@ local timestamps = config.timestamps; - if timestamps == true then + if timestamps == nil or timestamps == true then timestamps = default_timestamp; -- Default format end
--- a/net/server.lua Tue Jul 28 05:33:51 2009 +0500 +++ b/net/server.lua Tue Jul 28 19:17:09 2009 +0100 @@ -181,20 +181,41 @@ 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
--- a/net/xmppclient_listener.lua Tue Jul 28 05:33:51 2009 +0500 +++ b/net/xmppclient_listener.lua Tue Jul 28 19:17:09 2009 +0100 @@ -70,9 +70,14 @@ 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);
--- a/net/xmppcomponent_listener.lua Tue Jul 28 05:33:51 2009 +0500 +++ b/net/xmppcomponent_listener.lua Tue Jul 28 19:17:09 2009 +0100 @@ -87,9 +87,14 @@ --- 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);
--- a/net/xmppserver_listener.lua Tue Jul 28 05:33:51 2009 +0500 +++ b/net/xmppserver_listener.lua Tue Jul 28 19:17:09 2009 +0100 @@ -70,9 +70,14 @@ 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);
--- a/plugins/mod_console.lua Tue Jul 28 05:33:51 2009 +0500 +++ b/plugins/mod_console.lua Tue Jul 28 19:17:09 2009 +0100 @@ -156,6 +156,51 @@ 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