# HG changeset patch # User Matthew Wild # Date 1226631296 0 # Node ID 182f0c895676d092da3804d1c955debf7f9419c1 # Parent 1485d272400df17429c72cf2cef3ca8d2370d69b Now outgoing s2s sessions are associated with their from_host, fixes #15 diff -r 1485d272400d -r 182f0c895676 core/s2smanager.lua --- a/core/s2smanager.lua Fri Nov 14 02:41:37 2008 +0000 +++ b/core/s2smanager.lua Fri Nov 14 02:54:56 2008 +0000 @@ -32,7 +32,7 @@ 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 @@ 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 @@ 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 @@ 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; diff -r 1485d272400d -r 182f0c895676 main.lua --- a/main.lua Fri Nov 14 02:41:37 2008 +0000 +++ b/main.lua Fri Nov 14 02:54:56 2008 +0000 @@ -17,7 +17,7 @@ if config.hosts and #config.hosts > 0 then for _, host in pairs(config.hosts) do - hosts[host] = {type = "local", connected = true, sessions = {}, host = host}; + hosts[host] = {type = "local", connected = true, sessions = {}, host = host, s2sout = {} }; end else error("No hosts defined in the configuration file"); end diff -r 1485d272400d -r 182f0c895676 plugins/mod_dialback.lua --- a/plugins/mod_dialback.lua Fri Nov 14 02:41:37 2008 +0000 +++ b/plugins/mod_dialback.lua Fri Nov 14 02:54:56 2008 +0000 @@ -39,7 +39,7 @@ send_s2s(origin.to_host, origin.from_host, format("%s", origin.to_host, origin.from_host, origin.streamid, origin.dialback_key)); - hosts[origin.from_host].dialback_verifying = origin; + hosts[origin.to_host].s2sout[origin.from_host].dialback_verifying = origin; end); add_handler({ "s2sout_unauthed", "s2sout" }, "verify", xmlns_dialback,