Software /
code /
prosody
Changeset
279:76bad8b64018
Merging.
author | Tobias Markmann <tm@ayena.de> |
---|---|
date | Mon, 10 Nov 2008 16:29:19 +0100 |
parents | 278:770a78cd38d7 (current diff) 240:c48dbfa6b1a6 (diff) |
children | 280:516f4c901991 |
files | |
diffstat | 7 files changed, 44 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/core/s2smanager.lua Mon Nov 10 16:28:15 2008 +0100 +++ b/core/s2smanager.lua Mon Nov 10 16:29:19 2008 +0100 @@ -76,16 +76,19 @@ local cl = connlisteners_get("xmppserver"); local conn, handler = socket.tcp() - --FIXME: Below parameters (ports/ip) are incorrect (use SRV) - to_host = srvmap[to_host] or to_host; - conn:connect(to_host, 5269); - conn = wraptlsclient(cl, conn, to_host, 5269, 0, 1, hosts[from_host].ssl_ctx ); - host_session.conn = conn; + -- Register this outgoing connection so that xmppserver_listener knows about it -- otherwise it will assume it is a new incoming connection cl.register_outgoing(conn, host_session); + --FIXME: Below parameters (ports/ip) are incorrect (use SRV) + to_host = srvmap[to_host] or to_host; + conn:settimeout(0.1); + conn:connect(to_host, 5269); + conn = wraptlsclient(cl, conn, to_host, 5269, 0, 1, hosts[from_host].ssl_ctx ); + host_session.conn = conn; + do local conn_name = "s2sout"..tostring(conn):match("[a-f0-9]*$"); host_session.log = logger_init(conn_name);
--- a/core/stanza_router.lua Mon Nov 10 16:28:15 2008 +0100 +++ b/core/stanza_router.lua Mon Nov 10 16:29:19 2008 +0100 @@ -33,6 +33,7 @@ function core_process_stanza(origin, stanza) log("debug", "Received["..origin.type.."]: "..tostring(st.reply(st.reply(stanza)))) + if not stanza.attr.xmlns then stanza.attr.xmlns = "jabber:client"; end -- FIXME Hack. This should be removed when we fix namespace handling. -- TODO verify validity of stanza (as well as JID validity) if stanza.name == "iq" and not(#stanza.tags == 1 and stanza.tags[1].attr.xmlns) then if stanza.attr.type == "set" or stanza.attr.type == "get" then @@ -327,7 +328,7 @@ t_insert(recipients, session); end end - for _, session in pairs(recipient) do + for _, session in pairs(recipients) do session.send(stanza); end else
--- a/lxmppd.cfg.dist Mon Nov 10 16:28:15 2008 +0100 +++ b/lxmppd.cfg.dist Mon Nov 10 16:29:19 2008 +0100 @@ -26,5 +26,6 @@ "private"; "version"; "dialback"; + "uptime"; }; }
--- a/net/xmppclient_listener.lua Mon Nov 10 16:28:15 2008 +0100 +++ b/net/xmppclient_listener.lua Mon Nov 10 16:29:19 2008 +0100 @@ -62,7 +62,7 @@ -- (I'm on a mission, no time to fix now) -- Debug version -- - local function handleerr() print("Traceback:", debug.traceback()); end + local function handleerr(err) print("Traceback:", err, debug.traceback()); end session.stanza_dispatch = function (stanza) return select(2, xpcall(function () return core_process_stanza(session, stanza); end, handleerr)); end -- session.stanza_dispatch = function (stanza) return core_process_stanza(session, stanza); end
--- a/net/xmppserver_listener.lua Mon Nov 10 16:28:15 2008 +0100 +++ b/net/xmppserver_listener.lua Mon Nov 10 16:29:19 2008 +0100 @@ -64,7 +64,7 @@ -- (I'm on a mission, no time to fix now) -- Debug version -- - local function handleerr() print("Traceback:", debug.traceback()); end + local function handleerr(err) print("Traceback:", err, debug.traceback()); end session.stanza_dispatch = function (stanza) return select(2, xpcall(function () return core_process_stanza(session, stanza); end, handleerr)); end -- session.stanza_dispatch = function (stanza) return core_process_stanza(session, stanza); end
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/mod_uptime.lua Mon Nov 10 16:29:19 2008 +0100 @@ -0,0 +1,25 @@ + +local st = require "util.stanza" +local send = require "core.sessionmanager".send_to_session + +local jid_split = require "util.jid".split; +local t_concat = table.concat; + +local start_time = os.time(); + +add_iq_handler({"c2s", "s2sin"}, "jabber:iq:last", + function (origin, stanza) + if stanza.tags[1].name == "query" then + if stanza.attr.type == "get" then + local node, host, resource = jid_split(stanza.attr.to); + if node or resource then + -- TODO + else + origin.send(st.reply(stanza):tag("query", {xmlns = "jabber:iq:last", seconds = tostring(os.difftime(os.time(), start_time))})); + return true; + end + end + end + end); + +
--- a/tests/test_util_jid.lua Mon Nov 10 16:28:15 2008 +0100 +++ b/tests/test_util_jid.lua Mon Nov 10 16:29:19 2008 +0100 @@ -1,13 +1,14 @@ function split(split) - function test(jid, node, server, resource) - local rnode, rserver, rresource = split(jid); - assert_equal(node, rnode, "split("..jid..") failed"); - assert_equal(server, rserver, "split("..jid..") failed"); - assert_equal(resource, rresource, "split("..jid..") failed"); + function test(input_jid, expected_node, expected_server, expected_resource) + local rnode, rserver, rresource = split(input_jid); + assert_equal(expected_node, rnode, "split("..tostring(input_jid)..") failed"); + assert_equal(expected_server, rserver, "split("..tostring(input_jid)..") failed"); + assert_equal(expected_resource, rresource, "split("..tostring(input_jid)..") failed"); end test("node@server", "node", "server", nil ); test("node@server/resource", "node", "server", "resource" ); test("server", nil, "server", nil ); test("server/resource", nil, "server", "resource" ); + test(nil, nil, nil , nil ); end