X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=core%2Fs2smanager.lua;h=af5e91e3585705eb946b68a2ca3759a53848232c;hb=9a42b61e1f6522baf13a72f10d4c9fc24d1325f1;hp=30ac736b341e0a7209f0d6c48c403e91b988702a;hpb=e87485fe7ef126da3d534ff6c8e5f25d23e5559a;p=prosody.git diff --git a/core/s2smanager.lua b/core/s2smanager.lua index 30ac736b..af5e91e3 100644 --- a/core/s2smanager.lua +++ b/core/s2smanager.lua @@ -148,9 +148,10 @@ function new_incoming(conn) return session; end -function new_outgoing(from_host, to_host) +function new_outgoing(from_host, to_host, connect) local host_session = { to_host = to_host, from_host = from_host, host = from_host, - notopen = true, type = "s2sout_unauthed", direction = "outgoing" }; + notopen = true, type = "s2sout_unauthed", direction = "outgoing", + open_stream = session_open_stream }; hosts[from_host].s2sout[to_host] = host_session; @@ -161,8 +162,10 @@ function new_outgoing(from_host, to_host) host_session.log = log; end - -- Kick the connection attempting machine - attempt_connection(host_session); + if connect ~= false then + -- Kick the connection attempting machine into life + attempt_connection(host_session); + end if not host_session.sends2s then -- A sends2s which buffers data (until the stream is opened) @@ -324,7 +327,8 @@ function make_connect(host_session, connect_host, connect_port) local w, log = conn.write, host_session.log; host_session.sends2s = function (t) log("debug", "sending: %s", (t.top_tag and t:top_tag()) or t:match("^[^>]*>?")); w(conn, tostring(t)); end - conn:write(format([[]], from_host, to_host)); + host_session:open_stream(); + log("debug", "Connection attempt in progress..."); add_task(connect_timeout, function () if host_session.conn ~= conn or @@ -340,6 +344,13 @@ function make_connect(host_session, connect_host, connect_port) return true; end +function session_open_stream(session, from, to) + session.sends2s(st.stanza("stream:stream", { + xmlns='jabber:server', ["xmlns:db"]='jabber:server:dialback', + ["xmlns:stream"]='http://etherx.jabber.org/streams', + from=from, to=to, version='1.0', ["xml:lang"]='en'}):top_tag()); +end + function streamopened(session, attr) local send = session.sends2s;