diff options
author | Matthew Wild <mwild1@gmail.com> | 2010-03-14 03:03:02 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2010-03-14 03:03:02 +0000 |
commit | 4481ea54a304192f483ad704ba75ffd4398ec541 (patch) | |
tree | 4c07bff87d608cd2eab9319f2d908f2bb877ae1f /net | |
parent | ada4f197bba33b040746ab40fc64b50fe4523087 (diff) | |
download | prosody-4481ea54a304192f483ad704ba75ffd4398ec541.tar.gz prosody-4481ea54a304192f483ad704ba75ffd4398ec541.zip |
net.xmppcomponent_listener: Fix to correctly handle stream errors from components
Diffstat (limited to 'net')
-rw-r--r-- | net/xmppcomponent_listener.lua | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/net/xmppcomponent_listener.lua b/net/xmppcomponent_listener.lua index 0b98b6bc..2483d48a 100644 --- a/net/xmppcomponent_listener.lua +++ b/net/xmppcomponent_listener.lua @@ -34,16 +34,32 @@ local xmlns_component = 'jabber:component:accept'; local stream_callbacks = { default_ns = xmlns_component }; +local xmlns_xmpp_streams = "urn:ietf:params:xml:ns:xmpp-streams"; + function stream_callbacks.error(session, error, data, data2) log("warn", "Error processing component stream: "..tostring(error)); if error == "no-stream" then session:close("invalid-namespace"); - elseif error == "xml-parse-error" and data == "unexpected-element-close" then - session.log("warn", "Unexpected close of '%s' tag", data2); - session:close("xml-not-well-formed"); - else - session.log("warn", "External component %s XML parse error: %s", tostring(session.host), tostring(error)); + elseif error == "parse-error" then + session.log("warn", "External component %s XML parse error: %s", tostring(session.host), tostring(data)); session:close("xml-not-well-formed"); + elseif error == "stream-error" then + local condition, text = "undefined-condition"; + for child in data:children() do + if child.attr.xmlns == xmlns_xmpp_streams then + if child.name ~= "text" then + condition = child.name; + else + text = child:get_text(); + end + if condition ~= "undefined-condition" and text then + break; + end + end + end + text = condition .. (text and (" ("..text..")") or ""); + session.log("info", "Session closed by remote with error: %s", text); + session:close(nil, text); end end |