Software /
code /
prosody
Comparison
core/s2smanager.lua @ 260:182f0c895676
Now outgoing s2s sessions are associated with their from_host, fixes #15
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 14 Nov 2008 02:54:56 +0000 |
parent | 259:1485d272400d |
child | 265:1f851b6f5e11 |
comparison
equal
deleted
inserted
replaced
259:1485d272400d | 260:182f0c895676 |
---|---|
30 | 30 |
31 function connect_host(from_host, to_host) | 31 function connect_host(from_host, to_host) |
32 end | 32 end |
33 | 33 |
34 function send_to_host(from_host, to_host, data) | 34 function send_to_host(from_host, to_host, data) |
35 local host = hosts[to_host]; | 35 local host = hosts[from_host].s2sout[to_host]; |
36 if host then | 36 if host then |
37 -- We have a connection to this host already | 37 -- We have a connection to this host already |
38 if host.type == "s2sout_unauthed" then | 38 if host.type == "s2sout_unauthed" then |
39 host.log("debug", "trying to send over unauthed s2sout to "..to_host..", authing it now..."); | 39 host.log("debug", "trying to send over unauthed s2sout to "..to_host..", authing it now..."); |
40 if not host.notopen and not host.dialback_key then | 40 if not host.notopen and not host.dialback_key then |
50 log("error", "Traceback: %s", get_traceback()); | 50 log("error", "Traceback: %s", get_traceback()); |
51 log("error", "Stanza: %s", tostring(data)); | 51 log("error", "Stanza: %s", tostring(data)); |
52 else | 52 else |
53 (host.log or log)("debug", "going to send stanza to "..to_host.." from "..from_host); | 53 (host.log or log)("debug", "going to send stanza to "..to_host.." from "..from_host); |
54 -- FIXME | 54 -- FIXME |
55 if hosts[to_host].from_host ~= from_host then | 55 if host.from_host ~= from_host then |
56 log("error", "WARNING! This might, possibly, be a bug, but it might not..."); | 56 log("error", "WARNING! This might, possibly, be a bug, but it might not..."); |
57 log("error", "We are going to send from %s instead of %s", hosts[to_host].from_host, from_host); | 57 log("error", "We are going to send from %s instead of %s", host.from_host, from_host); |
58 end | 58 end |
59 hosts[to_host].sends2s(data); | 59 host.sends2s(data); |
60 host.log("debug", "stanza sent over "..hosts[to_host].type); | 60 host.log("debug", "stanza sent over "..host.type); |
61 end | 61 end |
62 else | 62 else |
63 log("debug", "opening a new outgoing connection for this stanza"); | 63 log("debug", "opening a new outgoing connection for this stanza"); |
64 local host_session = new_outgoing(from_host, to_host); | 64 local host_session = new_outgoing(from_host, to_host); |
65 -- Store in buffer | 65 -- Store in buffer |
85 return session; | 85 return session; |
86 end | 86 end |
87 | 87 |
88 function new_outgoing(from_host, to_host) | 88 function new_outgoing(from_host, to_host) |
89 local host_session = { to_host = to_host, from_host = from_host, notopen = true, type = "s2sout_unauthed", direction = "outgoing" }; | 89 local host_session = { to_host = to_host, from_host = from_host, notopen = true, type = "s2sout_unauthed", direction = "outgoing" }; |
90 hosts[to_host] = host_session; | 90 hosts[from_host].s2sout[to_host] = host_session; |
91 local cl = connlisteners_get("xmppserver"); | 91 local cl = connlisteners_get("xmppserver"); |
92 | 92 |
93 local conn, handler = socket.tcp() | 93 local conn, handler = socket.tcp() |
94 | 94 |
95 --FIXME: Below parameters (ports/ip) are incorrect (use SRV) | 95 --FIXME: Below parameters (ports/ip) are incorrect (use SRV) |
223 end | 223 end |
224 | 224 |
225 function destroy_session(session) | 225 function destroy_session(session) |
226 (session.log or log)("info", "Destroying "..tostring(session.direction).." session "..tostring(session.from_host).."->"..tostring(session.to_host)); | 226 (session.log or log)("info", "Destroying "..tostring(session.direction).." session "..tostring(session.from_host).."->"..tostring(session.to_host)); |
227 if session.direction == "outgoing" then | 227 if session.direction == "outgoing" then |
228 hosts[session.to_host] = nil; | 228 hosts[session.from_host].s2sout[session.to_host] = nil; |
229 end | 229 end |
230 session.conn = nil; | 230 session.conn = nil; |
231 session.disconnect = nil; | 231 session.disconnect = nil; |
232 for k in pairs(session) do | 232 for k in pairs(session) do |
233 if k ~= "trace" then | 233 if k ~= "trace" then |