From 564fb0420a1e83294462f83cfe735fac3aae7875 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 12 Nov 2008 19:26:08 +0000 Subject: Some s2s fixes. Now connect() does not block, and stanzas are not lost when connection is slow --- core/s2smanager.lua | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) (limited to 'core') diff --git a/core/s2smanager.lua b/core/s2smanager.lua index aed10753..1cfba592 100644 --- a/core/s2smanager.lua +++ b/core/s2smanager.lua @@ -31,18 +31,23 @@ end function send_to_host(from_host, to_host, data) local host = hosts[to_host]; if host then - -- Write to connection - if host.type == "s2sout_unauthed" and not host.notopen and not host.dialback_key then - log("debug", "trying to send over unauthed s2sout to "..to_host..", authing it now..."); - initiate_dialback(host); - if not host.sendq then host.sendq = { data }; - else t_insert(host.sendq, data); end + -- We have a connection to this host already + if host.type == "s2sout_unauthed" then + host.log("debug", "trying to send over unauthed s2sout to "..to_host..", authing it now..."); + if not host.notopen and not host.dialback_key then + host.log("debug", "dialback had not been initiated"); + initiate_dialback(host); + end + + -- Queue stanza until we are able to send it + if host.sendq then t_insert(host.sendq, data); + else host.sendq = { data }; end else - log("debug", "going to send stanza to "..to_host.." from "..from_host); + host.log("debug", "going to send stanza to "..to_host.." from "..from_host); -- FIXME if hosts[to_host].from_host ~= from_host then log("error", "WARNING! This might, possibly, be a bug, but it might not..."); end hosts[to_host].sends2s(data); - log("debug", "stanza sent over "..hosts[to_host].type); + host.log("debug", "stanza sent over "..hosts[to_host].type); end else log("debug", "opening a new outgoing connection for this stanza"); @@ -77,18 +82,22 @@ function new_outgoing(from_host, to_host) local conn, handler = socket.tcp() - - -- 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:settimeout(0); + local success, err = conn:connect(to_host, 5269); + if not success then + log("warn", "s2s connect() failed: %s", err); + end + 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); + do local conn_name = "s2sout"..tostring(conn):match("[a-f0-9]*$"); host_session.log = logger_init(conn_name); -- cgit v1.2.3 From a37d7db54f875e07c1bcc813265aaf112130b313 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 13 Nov 2008 03:48:20 +0000 Subject: Change sending reply stream header to use top_tag() --- core/s2smanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core') diff --git a/core/s2smanager.lua b/core/s2smanager.lua index 1cfba592..8a6d5b45 100644 --- a/core/s2smanager.lua +++ b/core/s2smanager.lua @@ -133,7 +133,7 @@ function streamopened(session, attr) session.streamid = uuid_gen(); print(session, session.from_host, "incoming s2s stream opened"); send(""); - send(format("", session.streamid, session.to_host)); + send(stanza("stream:stream", { xmlns='jabber:server', ["xmlns:db"]='jabber:server:dialback', ["xmlns:stream"]='http://etherx.jabber.org/streams', id=session.streamid, from=session.to_host })); elseif session.direction == "outgoing" then -- If we are just using the connection for verifying dialback keys, we won't try and auth it if not attr.id then error("stream response did not give us a streamid!!!"); end -- cgit v1.2.3 From 2a2cad9354e899fa367d8e5b8637e83400a3877c Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 13 Nov 2008 03:56:22 +0000 Subject: Missed importing a function in last commit --- core/s2smanager.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'core') diff --git a/core/s2smanager.lua b/core/s2smanager.lua index 8a6d5b45..276873cd 100644 --- a/core/s2smanager.lua +++ b/core/s2smanager.lua @@ -10,6 +10,8 @@ local tostring, pairs, ipairs, getmetatable, print, newproxy, error, tonumber local connlisteners_get = require "net.connlisteners".get; local wraptlsclient = require "net.server".wraptlsclient; local modulemanager = require "core.modulemanager"; +local st = require "stanza"; +local stanza = st.stanza; local uuid_gen = require "util.uuid".generate; -- cgit v1.2.3 From 093cf3e0172ee565202910a324261883d6ff5a5a Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Thu, 13 Nov 2008 12:13:13 +0500 Subject: Added basic offline message support --- core/offlinemanager.lua | 32 ++++++++++++++++++++++++++++++++ core/stanza_router.lua | 18 +++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 core/offlinemanager.lua (limited to 'core') diff --git a/core/offlinemanager.lua b/core/offlinemanager.lua new file mode 100644 index 00000000..283de5e3 --- /dev/null +++ b/core/offlinemanager.lua @@ -0,0 +1,32 @@ + +local datamanager = require "util.datamanager"; +local st = require "util.stanza"; +local datetime = require "util.datetime"; +local ipairs = ipairs; + +module "offlinemanager" + +function store(node, host, stanza) + stanza.attr.stamp = datetime.datetime(); + stanza.attr.stamp_legacy = datetime.legacy(); + return datamanager.list_append(node, host, "offline", st.preserialize(stanza)); +end + +function load(node, host) + local data = datamanager.list_load(node, host, "offline"); + if not data then return; end + for k, v in ipairs(data) do + stanza = st.deserialize(v); + stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = host, stamp = stanza.attr.stamp}):up(); -- XEP-0203 + stanza:tag("x", {xmlns = "jabber:x:delay", from = host, stamp = stanza.attr.stamp_legacy}):up(); -- XEP-0091 (deprecated) + stanza.attr.stamp, stanza.attr.stamp_legacy = nil, nil; + data[k] = stanza; + end + return data; +end + +function deleteAll(node, host) + return datamanager.list_store(node, host, "offline", nil); +end + +return _M; diff --git a/core/stanza_router.lua b/core/stanza_router.lua index 9ae98f1c..5d6358ec 100644 --- a/core/stanza_router.lua +++ b/core/stanza_router.lua @@ -13,6 +13,7 @@ local user_exists = require "core.usermanager".user_exists; local rostermanager = require "core.rostermanager"; local sessionmanager = require "core.sessionmanager"; +local offlinemanager = require "core.offlinemanager"; local s2s_verify_dialback = require "core.s2smanager".verify_dialback; local s2s_make_authenticated = require "core.s2smanager".make_authenticated; @@ -149,6 +150,10 @@ function core_handle_stanza(origin, stanza) core_route_stanza(origin, request); end end + for _, msg in ipairs(offlinemanager.load(node, host) or {}) do + origin.send(msg); -- FIXME do we need to modify to/from in any way? + end + offlinemanager.deleteAll(node, host); end origin.priority = 0; if stanza.attr.type == "unavailable" then @@ -328,8 +333,14 @@ function core_route_stanza(origin, stanza) t_insert(recipients, session); end end + local count = 0; for _, session in pairs(recipients) do session.send(stanza); + count = count + 1; + end + if count == 0 then + offlinemanager.store(node, host, stanza); + -- TODO deal with storage errors end else -- TODO send IQ error @@ -349,7 +360,12 @@ function core_route_stanza(origin, stanza) -- TODO send unavailable presence or unsubscribed end elseif stanza.name == "message" then - -- TODO send message error, or store offline messages + if stanza.attr.type == "chat" or stanza.attr.type == "normal" or not stanza.attr.type then + offlinemanager.store(node, host, stanza); + -- FIXME don't store messages with only chat state notifications + end + -- TODO allow configuration of offline storage + -- TODO send error if not storing offline elseif stanza.name == "iq" then -- TODO send IQ error end -- cgit v1.2.3 From a1740642f2a9af6bf42747fe0b4bf2148fc38449 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Thu, 13 Nov 2008 19:14:31 +0500 Subject: Added error replies for unhandled stanzas --- core/stanza_router.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/stanza_router.lua b/core/stanza_router.lua index 5d6358ec..1793f547 100644 --- a/core/stanza_router.lua +++ b/core/stanza_router.lua @@ -173,11 +173,16 @@ function core_handle_stanza(origin, stanza) end stanza.attr.to = nil; -- reset it else - -- TODO error, bad type + log("warn", "Unhandled c2s presence: %s", tostring(stanza)); + origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); -- FIXME correct error? end + else + log("warn", "Unhandled c2s stanza: %s", tostring(stanza)); + origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); -- FIXME correct error? end -- TODO handle other stanzas else - log("warn", "Unhandled origin: %s", origin.type); -- FIXME reply with error + log("warn", "Unhandled origin: %s", origin.type); + origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); -- FIXME correct error? end end -- cgit v1.2.3 From 3349550650708464ff95669a41003f8086181167 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 14 Nov 2008 02:06:17 +0000 Subject: Mmm, s2s fixed :) --- core/s2smanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core') diff --git a/core/s2smanager.lua b/core/s2smanager.lua index 276873cd..fe43b181 100644 --- a/core/s2smanager.lua +++ b/core/s2smanager.lua @@ -135,7 +135,7 @@ function streamopened(session, attr) session.streamid = uuid_gen(); print(session, session.from_host, "incoming s2s stream opened"); send(""); - send(stanza("stream:stream", { xmlns='jabber:server', ["xmlns:db"]='jabber:server:dialback', ["xmlns:stream"]='http://etherx.jabber.org/streams', id=session.streamid, from=session.to_host })); + send(stanza("stream:stream", { xmlns='jabber:server', ["xmlns:db"]='jabber:server:dialback', ["xmlns:stream"]='http://etherx.jabber.org/streams', id=session.streamid, from=session.to_host }):top_tag()); elseif session.direction == "outgoing" then -- If we are just using the connection for verifying dialback keys, we won't try and auth it if not attr.id then error("stream response did not give us a streamid!!!"); end -- cgit v1.2.3 From e110538068747e6595facc504f775c3555d546b8 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 14 Nov 2008 02:09:20 +0000 Subject: Another small fix, for logging in s2smanager --- core/s2smanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core') diff --git a/core/s2smanager.lua b/core/s2smanager.lua index fe43b181..f5ad12f9 100644 --- a/core/s2smanager.lua +++ b/core/s2smanager.lua @@ -45,7 +45,7 @@ function send_to_host(from_host, to_host, data) if host.sendq then t_insert(host.sendq, data); else host.sendq = { data }; end else - host.log("debug", "going to send stanza to "..to_host.." from "..from_host); + (host.log or log)("debug", "going to send stanza to "..to_host.." from "..from_host); -- FIXME if hosts[to_host].from_host ~= from_host then log("error", "WARNING! This might, possibly, be a bug, but it might not..."); end hosts[to_host].sends2s(data); -- cgit v1.2.3 From 9acd51fbef35196c355bf03a9d7751a064649d29 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 14 Nov 2008 02:12:08 +0000 Subject: Another small fix, for logging in s2smanager --- core/s2smanager.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'core') diff --git a/core/s2smanager.lua b/core/s2smanager.lua index f5ad12f9..e0a6f3ca 100644 --- a/core/s2smanager.lua +++ b/core/s2smanager.lua @@ -47,7 +47,10 @@ function send_to_host(from_host, to_host, data) else (host.log or log)("debug", "going to send stanza to "..to_host.." from "..from_host); -- FIXME - if hosts[to_host].from_host ~= from_host then log("error", "WARNING! This might, possibly, be a bug, but it might not..."); end + if hosts[to_host].from_host ~= from_host then + log("error", "WARNING! This might, possibly, be a bug, but it might not..."); + log("error", "We are going to send from %s instead of %s", hosts[to_host].from_host, from_host); + end hosts[to_host].sends2s(data); host.log("debug", "stanza sent over "..hosts[to_host].type); end -- cgit v1.2.3 From 1b422e8f1d173e7f70db93cfec3ef499e0f9e37c Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 14 Nov 2008 02:20:46 +0000 Subject: Fix for detecting when we are routing a stanza to ourself (I'm sure this has something to do with you, waqas...) --- core/s2smanager.lua | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'core') diff --git a/core/s2smanager.lua b/core/s2smanager.lua index e0a6f3ca..16092ba8 100644 --- a/core/s2smanager.lua +++ b/core/s2smanager.lua @@ -4,6 +4,7 @@ local sessions = sessions; local socket = require "socket"; local format = string.format; local t_insert = table.insert; +local get_traceback = debug.traceback; local tostring, pairs, ipairs, getmetatable, print, newproxy, error, tonumber = tostring, pairs, ipairs, getmetatable, print, newproxy, error, tonumber; @@ -44,6 +45,9 @@ function send_to_host(from_host, to_host, data) -- Queue stanza until we are able to send it if host.sendq then t_insert(host.sendq, data); else host.sendq = { data }; end + elseif host.type == "local" or host.type == "component" then + log("error", "Trying to send a stanza to ourselves??") + log("error", "Traceback: "..get_traceback()); else (host.log or log)("debug", "going to send stanza to "..to_host.." from "..from_host); -- FIXME -- cgit v1.2.3 From f980ba5734e2a81348f14905147519b26ef8d794 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 14 Nov 2008 02:23:43 +0000 Subject: Print out the stanza also --- core/s2smanager.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'core') diff --git a/core/s2smanager.lua b/core/s2smanager.lua index 16092ba8..530e3087 100644 --- a/core/s2smanager.lua +++ b/core/s2smanager.lua @@ -47,7 +47,8 @@ function send_to_host(from_host, to_host, data) else host.sendq = { data }; end elseif host.type == "local" or host.type == "component" then log("error", "Trying to send a stanza to ourselves??") - log("error", "Traceback: "..get_traceback()); + log("error", "Traceback: %s", get_traceback()); + log("error", "Stanza: %s", stanza); else (host.log or log)("debug", "going to send stanza to "..to_host.." from "..from_host); -- FIXME -- cgit v1.2.3 From c374478423b1fa6df31f2e133db77f89ceb91fac Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 14 Nov 2008 02:33:20 +0000 Subject: I knew it ;) Fix sending error replies over s2s (though we shouldn't be error'ing on stream:features anyway) --- core/s2smanager.lua | 2 +- core/stanza_router.lua | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/s2smanager.lua b/core/s2smanager.lua index 530e3087..8b421f13 100644 --- a/core/s2smanager.lua +++ b/core/s2smanager.lua @@ -48,7 +48,7 @@ function send_to_host(from_host, to_host, data) elseif host.type == "local" or host.type == "component" then log("error", "Trying to send a stanza to ourselves??") log("error", "Traceback: %s", get_traceback()); - log("error", "Stanza: %s", stanza); + log("error", "Stanza: %s", data); else (host.log or log)("debug", "going to send stanza to "..to_host.." from "..from_host); -- FIXME diff --git a/core/stanza_router.lua b/core/stanza_router.lua index 1793f547..6c117c25 100644 --- a/core/stanza_router.lua +++ b/core/stanza_router.lua @@ -182,7 +182,8 @@ function core_handle_stanza(origin, stanza) end -- TODO handle other stanzas else log("warn", "Unhandled origin: %s", origin.type); - origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); -- FIXME correct error? + -- s2s stanzas can get here + (origin.sends2s or origin.send)(st.error_reply(stanza, "cancel", "service-unavailable")); -- FIXME correct error? end end -- cgit v1.2.3 From 6d9485225a4c8c9b339ca9cea137ba3f2de6fd64 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 14 Nov 2008 02:38:41 +0000 Subject: Yep, s2s definitely works now. This is just a small fix for logging... --- core/s2smanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core') diff --git a/core/s2smanager.lua b/core/s2smanager.lua index 8b421f13..4fa22957 100644 --- a/core/s2smanager.lua +++ b/core/s2smanager.lua @@ -48,7 +48,7 @@ function send_to_host(from_host, to_host, data) elseif host.type == "local" or host.type == "component" then log("error", "Trying to send a stanza to ourselves??") log("error", "Traceback: %s", get_traceback()); - log("error", "Stanza: %s", data); + log("error", "Stanza: %s", tostring(data)); else (host.log or log)("debug", "going to send stanza to "..to_host.." from "..from_host); -- FIXME -- cgit v1.2.3 From 428fc65bbc595d80cb678dadcc9ea7cae055d5b9 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 14 Nov 2008 02:41:37 +0000 Subject: Some more logging fixes --- core/s2smanager.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'core') diff --git a/core/s2smanager.lua b/core/s2smanager.lua index 4fa22957..6d00ff6e 100644 --- a/core/s2smanager.lua +++ b/core/s2smanager.lua @@ -103,11 +103,11 @@ function new_outgoing(from_host, to_host) 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); - + do local conn_name = "s2sout"..tostring(conn):match("[a-f0-9]*$"); host_session.log = logger_init(conn_name); @@ -122,7 +122,6 @@ function new_outgoing(from_host, to_host) end function streamopened(session, attr) - session.log("debug", "s2s stream opened"); local send = session.sends2s; session.version = tonumber(attr.version) or 0; @@ -166,7 +165,7 @@ function streamopened(session, attr) end send("");]] - log("info", "s2s stream opened successfully"); + session.notopen = nil; end -- cgit v1.2.3 From 22df06d27db30cae5c7d3361a4fe51ab9a89dcbc Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 14 Nov 2008 02:54:56 +0000 Subject: Now outgoing s2s sessions are associated with their from_host, fixes #15 --- core/s2smanager.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'core') diff --git a/core/s2smanager.lua b/core/s2smanager.lua index 6d00ff6e..3f286d0e 100644 --- a/core/s2smanager.lua +++ b/core/s2smanager.lua @@ -32,7 +32,7 @@ function connect_host(from_host, to_host) end function send_to_host(from_host, to_host, data) - local host = hosts[to_host]; + local host = hosts[from_host].s2sout[to_host]; if host then -- We have a connection to this host already if host.type == "s2sout_unauthed" then @@ -52,12 +52,12 @@ function send_to_host(from_host, to_host, data) else (host.log or log)("debug", "going to send stanza to "..to_host.." from "..from_host); -- FIXME - if hosts[to_host].from_host ~= from_host then + if host.from_host ~= from_host then log("error", "WARNING! This might, possibly, be a bug, but it might not..."); - log("error", "We are going to send from %s instead of %s", hosts[to_host].from_host, from_host); + log("error", "We are going to send from %s instead of %s", host.from_host, from_host); end - hosts[to_host].sends2s(data); - host.log("debug", "stanza sent over "..hosts[to_host].type); + host.sends2s(data); + host.log("debug", "stanza sent over "..host.type); end else log("debug", "opening a new outgoing connection for this stanza"); @@ -87,7 +87,7 @@ end function new_outgoing(from_host, to_host) local host_session = { to_host = to_host, from_host = from_host, notopen = true, type = "s2sout_unauthed", direction = "outgoing" }; - hosts[to_host] = host_session; + hosts[from_host].s2sout[to_host] = host_session; local cl = connlisteners_get("xmppserver"); local conn, handler = socket.tcp() @@ -225,7 +225,7 @@ end function destroy_session(session) (session.log or log)("info", "Destroying "..tostring(session.direction).." session "..tostring(session.from_host).."->"..tostring(session.to_host)); if session.direction == "outgoing" then - hosts[session.to_host] = nil; + hosts[session.from_host].s2sout[session.to_host] = nil; end session.conn = nil; session.disconnect = nil; -- cgit v1.2.3 From be854cf8995560ecb4cf61e3d7f9823e970c0521 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 14 Nov 2008 14:26:56 +0000 Subject: Fix outgoing s2s from components. Fixes #16 --- core/componentmanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core') diff --git a/core/componentmanager.lua b/core/componentmanager.lua index 38718882..254abfe4 100644 --- a/core/componentmanager.lua +++ b/core/componentmanager.lua @@ -25,7 +25,7 @@ function register_component(host, component) if not hosts[host] then -- TODO check for host well-formedness components[host] = component; - hosts[host] = {type = "component", host = host, connected = true}; + hosts[host] = {type = "component", host = host, connected = true, s2sout = {} }; log("debug", "component added: "..host); else log("error", "Attempt to set component for existing host: "..host); -- cgit v1.2.3 From d67940a1d7700c0389341c42f845b91e8b32eea6 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 14 Nov 2008 16:03:33 +0000 Subject: A treat for Linux users ;) --- core/stanza_router.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core') diff --git a/core/stanza_router.lua b/core/stanza_router.lua index 6c117c25..16e6598f 100644 --- a/core/stanza_router.lua +++ b/core/stanza_router.lua @@ -32,7 +32,7 @@ local jid_split = require "util.jid".split; local print = print; function core_process_stanza(origin, stanza) - log("debug", "Received["..origin.type.."]: "..tostring(st.reply(st.reply(stanza)))) + log("debug", "Received[%s]: %s", origin.type, stanza:pretty_top_tag()) 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) -- cgit v1.2.3 From 44701835b153e9497a8a5f634ece17ffda41c5ca Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 14 Nov 2008 17:37:45 +0000 Subject: Update rostermanager to use new logger --- core/rostermanager.lua | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'core') diff --git a/core/rostermanager.lua b/core/rostermanager.lua index 9a203337..235f2aee 100644 --- a/core/rostermanager.lua +++ b/core/rostermanager.lua @@ -1,8 +1,6 @@ -local mainlog = log; -local function log(type, message) - mainlog(type, "rostermanager", message); -end + +local log = require "util.logger".init("rostermanager"); local setmetatable = setmetatable; local format = string.format; -- cgit v1.2.3 From 50e328e87fb21ffca2780128ed5da9c0e011eb5f Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 14 Nov 2008 18:46:00 +0000 Subject: Only reply with errors if the stanza is not an error or a result (don't know how much bandwidth this just cost me :) ) --- core/stanza_router.lua | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'core') diff --git a/core/stanza_router.lua b/core/stanza_router.lua index 16e6598f..c1819651 100644 --- a/core/stanza_router.lua +++ b/core/stanza_router.lua @@ -174,16 +174,22 @@ function core_handle_stanza(origin, stanza) stanza.attr.to = nil; -- reset it else log("warn", "Unhandled c2s presence: %s", tostring(stanza)); - origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); -- FIXME correct error? + if stanza.attr.type ~= "error" then + origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); -- FIXME correct error? + end end else log("warn", "Unhandled c2s stanza: %s", tostring(stanza)); - origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); -- FIXME correct error? + if stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then + origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); -- FIXME correct error? + end end -- TODO handle other stanzas else log("warn", "Unhandled origin: %s", origin.type); - -- s2s stanzas can get here - (origin.sends2s or origin.send)(st.error_reply(stanza, "cancel", "service-unavailable")); -- FIXME correct error? + if stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then + -- s2s stanzas can get here + (origin.sends2s or origin.send)(st.error_reply(stanza, "cancel", "service-unavailable")); -- FIXME correct error? + end end end -- cgit v1.2.3 From b06c5faec463339f95023abb0b1e2aa09dbefd7c Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 14 Nov 2008 18:54:19 +0000 Subject: Remove some old unused (and empty) functions from s2smanager --- core/s2smanager.lua | 7 ------- 1 file changed, 7 deletions(-) (limited to 'core') diff --git a/core/s2smanager.lua b/core/s2smanager.lua index 3f286d0e..490dfec4 100644 --- a/core/s2smanager.lua +++ b/core/s2smanager.lua @@ -28,9 +28,6 @@ local srvmap = { ["gmail.com"] = "talk.google.com", ["identi.ca"] = "longlance.c module "s2smanager" -function connect_host(from_host, to_host) -end - function send_to_host(from_host, to_host, data) local host = hosts[from_host].s2sout[to_host]; if host then @@ -67,10 +64,6 @@ function send_to_host(from_host, to_host, data) end end -function disconnect_host(host) - -end - local open_sessions = 0; function new_incoming(conn) -- cgit v1.2.3 From 1c704dcef79c640ffdbc259af63c29ac47599e89 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 14 Nov 2008 20:30:24 +0000 Subject: Update hostname for identi.ca --- core/s2smanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core') diff --git a/core/s2smanager.lua b/core/s2smanager.lua index 490dfec4..bec1c29b 100644 --- a/core/s2smanager.lua +++ b/core/s2smanager.lua @@ -24,7 +24,7 @@ local md5_hash = require "util.hashes".md5; local dialback_secret = "This is very secret!!! Ha!"; -local srvmap = { ["gmail.com"] = "talk.google.com", ["identi.ca"] = "longlance.controlezvous.ca", ["cdr.se"] = "jabber.cdr.se" }; +local srvmap = { ["gmail.com"] = "talk.google.com", ["identi.ca"] = "hampton.controlezvous.ca", ["cdr.se"] = "jabber.cdr.se" }; module "s2smanager" -- cgit v1.2.3 From fc57c3a09a9ca234f45bb3a1e9b3d8fd8d48d2e0 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Sat, 15 Nov 2008 05:33:14 +0500 Subject: Some bugs fixed --- core/offlinemanager.lua | 2 +- core/rostermanager.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/offlinemanager.lua b/core/offlinemanager.lua index 283de5e3..e71da446 100644 --- a/core/offlinemanager.lua +++ b/core/offlinemanager.lua @@ -16,7 +16,7 @@ function load(node, host) local data = datamanager.list_load(node, host, "offline"); if not data then return; end for k, v in ipairs(data) do - stanza = st.deserialize(v); + local stanza = st.deserialize(v); stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = host, stamp = stanza.attr.stamp}):up(); -- XEP-0203 stanza:tag("x", {xmlns = "jabber:x:delay", from = host, stamp = stanza.attr.stamp_legacy}):up(); -- XEP-0091 (deprecated) stanza.attr.stamp, stanza.attr.stamp_legacy = nil, nil; diff --git a/core/rostermanager.lua b/core/rostermanager.lua index 9a203337..504d9961 100644 --- a/core/rostermanager.lua +++ b/core/rostermanager.lua @@ -234,7 +234,7 @@ function unsubscribed(username, host, jid) if item.subscription == "from" then item.subscription = "none"; changed = true; - elseif item.subscription == both then + elseif item.subscription == "both" then item.subscription = "to"; changed = true; end -- cgit v1.2.3 From 9318711f5f25a04aea6fe2fc9caa79a322a004b3 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Sat, 15 Nov 2008 08:38:25 +0500 Subject: Log how many queued stanzas we send --- core/s2smanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core') diff --git a/core/s2smanager.lua b/core/s2smanager.lua index bec1c29b..c3d9bdb4 100644 --- a/core/s2smanager.lua +++ b/core/s2smanager.lua @@ -205,7 +205,7 @@ function mark_connected(session) if session.direction == "outgoing" then if sendq then - session.log("debug", "sending queued stanzas across new outgoing connection to "..session.to_host); + session.log("debug", "sending "..#sendq.." queued stanzas across new outgoing connection to "..session.to_host); for i, data in ipairs(sendq) do send(data); sendq[i] = nil; -- cgit v1.2.3 From 32a4306f7afef43e355d5f1a82f9ae23ecba363b Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sat, 15 Nov 2008 04:28:41 +0000 Subject: Return registered host table when registering a component --- core/componentmanager.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'core') diff --git a/core/componentmanager.lua b/core/componentmanager.lua index 254abfe4..5b655435 100644 --- a/core/componentmanager.lua +++ b/core/componentmanager.lua @@ -27,6 +27,7 @@ function register_component(host, component) components[host] = component; hosts[host] = {type = "component", host = host, connected = true, s2sout = {} }; log("debug", "component added: "..host); + return hosts[host]; else log("error", "Attempt to set component for existing host: "..host); end -- cgit v1.2.3