aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2010-01-09 06:53:23 +0000
committerMatthew Wild <mwild1@gmail.com>2010-01-09 06:53:23 +0000
commit0d8ce51b7813684f2130626d2a3aabdb9f9bb11e (patch)
treef2dd49c96991db634934a87d50115466e0763238
parent76940508d1f8f2ab65d8b98c16960fa50d512da4 (diff)
downloadprosody-0d8ce51b7813684f2130626d2a3aabdb9f9bb11e.tar.gz
prosody-0d8ce51b7813684f2130626d2a3aabdb9f9bb11e.zip
s2smanager: Split sending of stream header into a :open_stream() method
-rw-r--r--core/s2smanager.lua13
1 files changed, 11 insertions, 2 deletions
diff --git a/core/s2smanager.lua b/core/s2smanager.lua
index 42aa1016..af5e91e3 100644
--- a/core/s2smanager.lua
+++ b/core/s2smanager.lua
@@ -150,7 +150,8 @@ end
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;
@@ -326,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([[<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));
+ host_session:open_stream();
+
log("debug", "Connection attempt in progress...");
add_task(connect_timeout, function ()
if host_session.conn ~= conn or
@@ -342,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;