Mercurial > prosody-hg
comparison core/s2smanager.lua @ 2127:be3c906f4770
s2smanager: Update for new net.server API (s2s still doesn't work with libevent for other reasons)
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sun, 22 Nov 2009 04:42:03 +0000 |
| parents | 7810648ea26d |
| children | 5c1758ccf8b9 |
comparison
equal
deleted
inserted
replaced
| 2126:12669db7ed4a | 2127:be3c906f4770 |
|---|---|
| 126 getmetatable(session.trace).__gc = function () open_sessions = open_sessions - 1; end; | 126 getmetatable(session.trace).__gc = function () open_sessions = open_sessions - 1; end; |
| 127 end | 127 end |
| 128 open_sessions = open_sessions + 1; | 128 open_sessions = open_sessions + 1; |
| 129 local w, log = conn.write, logger_init("s2sin"..tostring(conn):match("[a-f0-9]+$")); | 129 local w, log = conn.write, logger_init("s2sin"..tostring(conn):match("[a-f0-9]+$")); |
| 130 session.log = log; | 130 session.log = log; |
| 131 session.sends2s = function (t) log("debug", "sending: %s", tostring(t)); w(tostring(t)); end | 131 session.sends2s = function (t) log("debug", "sending: %s", tostring(t)); w(conn, tostring(t)); end |
| 132 incoming_s2s[session] = true; | 132 incoming_s2s[session] = true; |
| 133 add_task(connect_timeout, function () | 133 add_task(connect_timeout, function () |
| 134 if session.conn ~= conn or | 134 if session.conn ~= conn or |
| 135 session.type == "s2sin" then | 135 session.type == "s2sin" then |
| 136 return; -- Ok, we're connect[ed|ing] | 136 return; -- Ok, we're connect[ed|ing] |
| 315 -- Register this outgoing connection so that xmppserver_listener knows about it | 315 -- Register this outgoing connection so that xmppserver_listener knows about it |
| 316 -- otherwise it will assume it is a new incoming connection | 316 -- otherwise it will assume it is a new incoming connection |
| 317 cl.register_outgoing(conn, host_session); | 317 cl.register_outgoing(conn, host_session); |
| 318 | 318 |
| 319 local w, log = conn.write, host_session.log; | 319 local w, log = conn.write, host_session.log; |
| 320 host_session.sends2s = function (t) log("debug", "sending: %s", tostring(t)); w(tostring(t)); end | 320 host_session.sends2s = function (t) log("debug", "sending: %s", tostring(t)); w(conn, tostring(t)); end |
| 321 | 321 |
| 322 conn.write(format([[<stream:stream xmlns='jabber:server' xmlns:db='jabber:server:dialback' xmlns:stream='http://etherx.jabber.org/streams' from='%s' to='%s' version='1.0' xml:lang='en'>]], from_host, to_host)); | 322 conn:write(format([[<stream:stream xmlns='jabber:server' xmlns:db='jabber:server:dialback' xmlns:stream='http://etherx.jabber.org/streams' from='%s' to='%s' version='1.0' xml:lang='en'>]], from_host, to_host)); |
| 323 log("debug", "Connection attempt in progress..."); | 323 log("debug", "Connection attempt in progress..."); |
| 324 add_task(connect_timeout, function () | 324 add_task(connect_timeout, function () |
| 325 if host_session.conn ~= conn or | 325 if host_session.conn ~= conn or |
| 326 host_session.type == "s2sout" or | 326 host_session.type == "s2sout" or |
| 327 host_session.connecting then | 327 host_session.connecting then |
