aboutsummaryrefslogtreecommitdiffstats
path: root/net/xmppcomponent_listener.lua
diff options
context:
space:
mode:
Diffstat (limited to 'net/xmppcomponent_listener.lua')
-rw-r--r--net/xmppcomponent_listener.lua26
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