diff options
author | Matthew Wild <mwild1@gmail.com> | 2008-12-04 19:21:50 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2008-12-04 19:21:50 +0000 |
commit | 64499bf0d8d6043fd1c2897a759d3e02c22ab9a9 (patch) | |
tree | 2d536be7a266a0dccd47e61d776e721c8d116fea /core | |
parent | ad4d4c6eeeef52ecf93a3cced0c19ef569f2f213 (diff) | |
parent | a1173c8d66cdfd8f22d34c09508a20098819bdbf (diff) | |
download | prosody-64499bf0d8d6043fd1c2897a759d3e02c22ab9a9.tar.gz prosody-64499bf0d8d6043fd1c2897a759d3e02c22ab9a9.zip |
Automated merge with http://waqas.ath.cx/
Diffstat (limited to 'core')
-rw-r--r-- | core/s2smanager.lua | 6 | ||||
-rw-r--r-- | core/xmlhandlers.lua | 20 |
2 files changed, 15 insertions, 11 deletions
diff --git a/core/s2smanager.lua b/core/s2smanager.lua index 0afb8805..df877767 100644 --- a/core/s2smanager.lua +++ b/core/s2smanager.lua @@ -108,7 +108,7 @@ function new_outgoing(from_host, to_host) local log; do - local conn_name = "s2sout"..tostring(conn):match("[a-f0-9]*$"); + local conn_name = "s2sout"..tostring(host_session):match("[a-f0-9]*$"); log = logger_init(conn_name); host_session.log = log; end @@ -180,7 +180,9 @@ end function streamopened(session, attr) local send = session.sends2s; - session.version = tonumber(attr.version) or 0; + -- TODO: #29: SASL/TLS on s2s streams + session.version = 0; --tonumber(attr.version) or 0; + if session.version >= 1.0 and not (attr.to and attr.from) then --print("to: "..tostring(attr.to).." from: "..tostring(attr.from)); log("warn", (session.to_host or "(unknown)").." failed to specify 'to' or 'from' hostname as per RFC"); diff --git a/core/xmlhandlers.lua b/core/xmlhandlers.lua index ec3051b4..2872a036 100644 --- a/core/xmlhandlers.lua +++ b/core/xmlhandlers.lua @@ -52,12 +52,13 @@ function init_xmlhandlers(session, stream_callbacks) local chardata = {}; local xml_handlers = {}; local log = session.log or default_log; - --local print = function (...) log("info", "xmlhandlers", t_concatall({...}, "\t")); end - + local send = session.send; local cb_streamopened = stream_callbacks.streamopened; local cb_streamclosed = stream_callbacks.streamclosed; + local cb_error = stream_callbacks.error or function (e) error("XML stream error: "..tostring(e)); end; + local cb_handlestanza = stream_callbacks.handlestanza; local stanza function xml_handlers:StartElement(name, attr) @@ -92,12 +93,14 @@ function init_xmlhandlers(session, stream_callbacks) if cb_streamopened then cb_streamopened(session, attr); end - return; + else + -- Garbage before stream? + cb_error("no-stream"); end - error("Client failed to open stream successfully"); + return; end if curr_ns == "jabber:client" and name ~= "iq" and name ~= "presence" and name ~= "message" then - error("Client sent invalid top-level stanza"); + cb_error("invalid-top-level-element"); end stanza = st.stanza(name, attr); @@ -119,15 +122,14 @@ function init_xmlhandlers(session, stream_callbacks) curr_ns,name = name:match("^(.+)|([%w%-]+)$"); if (not stanza) or (#stanza.last_add > 0 and name ~= stanza.last_add[#stanza.last_add].name) then if name == "stream" then - log("debug", "Stream closed"); if cb_streamclosed then cb_streamclosed(session); end return; elseif name == "error" then - error("Stream error: "..tostring(name)..": "..tostring(stanza)); + cb_error("stream-error", stanza); else - error("XML parse error in client stream with element: "..name); + cb_error("parse-error", "unexpected-element-close", name); end end if stanza and #chardata > 0 then @@ -137,7 +139,7 @@ function init_xmlhandlers(session, stream_callbacks) end -- Complete stanza if #stanza.last_add == 0 then - session.stanza_dispatch(stanza); + cb_handlestanza(session, stanza); stanza = nil; else stanza:up(); |