diff options
author | Kim Alvefur <zash@zash.se> | 2013-03-16 18:49:14 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2013-03-16 18:49:14 +0100 |
commit | 478a2d42e6f1be1c45732d3851a65a99ea09565c (patch) | |
tree | a097c4f3a59bd0cc87d76bf637dff458fb5ff330 /plugins/mod_s2s | |
parent | 58049837e7a14744f37d0250c3a854bc312d9106 (diff) | |
parent | ee9ef878c4f1702f3bacfd8d3c0c98844c3b481f (diff) | |
download | prosody-478a2d42e6f1be1c45732d3851a65a99ea09565c.tar.gz prosody-478a2d42e6f1be1c45732d3851a65a99ea09565c.zip |
Merge 0.9->trunk
Diffstat (limited to 'plugins/mod_s2s')
-rw-r--r-- | plugins/mod_s2s/mod_s2s.lua | 31 | ||||
-rw-r--r-- | plugins/mod_s2s/s2sout.lib.lua | 8 |
2 files changed, 26 insertions, 13 deletions
diff --git a/plugins/mod_s2s/mod_s2s.lua b/plugins/mod_s2s/mod_s2s.lua index 6d4900fa..8d99b855 100644 --- a/plugins/mod_s2s/mod_s2s.lua +++ b/plugins/mod_s2s/mod_s2s.lua @@ -248,10 +248,7 @@ function stream_callbacks.streamopened(session, attr) if session.secure and not session.cert_chain_status then check_cert_status(session); end - send("<?xml version='1.0'?>"); - send(st.stanza("stream:stream", { xmlns='jabber:server', - ["xmlns:db"]= hosts[to].modules.dialback and 'jabber:server:dialback' or nil, - ["xmlns:stream"]='http://etherx.jabber.org/streams', id=session.streamid, from=to, to=from, version=(session.version > 0 and "1.0" or nil) }):top_tag()); + session:open_stream() if session.version >= 1.0 then local features = st.stanza("stream:features"); @@ -348,8 +345,7 @@ local function session_close(session, reason, remote_reason) local log = session.log or log; if session.conn then if session.notopen then - session.sends2s("<?xml version='1.0'?>"); - session.sends2s(st.stanza("stream:stream", default_stream_attr):top_tag()); + session:open_stream() end if reason then -- nil == no err, initiated by us, false == initiated by remote if type(reason) == "string" then -- assume stream error @@ -396,6 +392,27 @@ local function session_close(session, reason, remote_reason) end end +function session_open_stream(session, from, to) + local from = from or session.from_host; + local to = to or session.to_host; + local attr = { + ["xmlns:stream"] = 'http://etherx.jabber.org/streams', + xmlns = 'jabber:server', + version = session.version and (session.version > 0 and "1.0" or nil), + ["xml:lang"] = 'en', + id = session.streamid, + from = from, to = to, + } + local local_host = session.direction == "outgoing" and from or to; + if not local_host or hosts[local_host].modules.dialback then + attr["xmlns:db"] = 'jabber:server:dialback'; + end + + session.sends2s("<?xml version='1.0'?>"); + session.sends2s(st.stanza("stream:stream", attr):top_tag()); + return true; +end + -- Session initialization logic shared by incoming and outgoing local function initialize_session(session) local stream = new_xmpp_stream(session, stream_callbacks); @@ -407,6 +424,8 @@ local function initialize_session(session) session.notopen = true; session.stream:reset(); end + + session.open_stream = session_open_stream; local filter = session.filter; function session.data(data) diff --git a/plugins/mod_s2s/s2sout.lib.lua b/plugins/mod_s2s/s2sout.lib.lua index 07623968..5ebbee8e 100644 --- a/plugins/mod_s2s/s2sout.lib.lua +++ b/plugins/mod_s2s/s2sout.lib.lua @@ -44,15 +44,9 @@ local function compare_srv_priorities(a,b) return a.priority < b.priority or (a.priority == b.priority and a.weight > b.weight); end -local 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 s2sout.initiate_connection(host_session) initialize_filters(host_session); + host_session.version = 1; host_session.open_stream = session_open_stream; -- Kick the connection attempting machine into life |