aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2010-01-19 04:38:43 +0000
committerMatthew Wild <mwild1@gmail.com>2010-01-19 04:38:43 +0000
commit9fee99dbb900c237ef082c073aa5945a64ba6f95 (patch)
tree3c76ca15ee6b3fd2887e38602f376840313a0528
parent7404385817009bcffd56c8aa8f91ac14ea8fc53b (diff)
downloadprosody-9fee99dbb900c237ef082c073aa5945a64ba6f95.tar.gz
prosody-9fee99dbb900c237ef082c073aa5945a64ba6f95.zip
net.xmppserver_listener: Handle stream-error errors from xmlhandlers, and close session in response
-rw-r--r--net/xmppserver_listener.lua21
1 files changed, 20 insertions, 1 deletions
diff --git a/net/xmppserver_listener.lua b/net/xmppserver_listener.lua
index 3def46b5..7fe012af 100644
--- a/net/xmppserver_listener.lua
+++ b/net/xmppserver_listener.lua
@@ -20,12 +20,31 @@ local s2s_attempt_connect = require "core.s2smanager".attempt_connection;
local stream_callbacks = { default_ns = "jabber:server",
streamopened = s2s_streamopened, streamclosed = s2s_streamclosed, handlestanza = core_process_stanza };
+local xmlns_xmpp_streams = "urn:ietf:params:xml:ns:xmpp-streams";
+
function stream_callbacks.error(session, error, data)
if error == "no-stream" then
session:close("invalid-namespace");
- else
+ elseif error == "parse-error" then
session.log("debug", "Server-to-server XML parse error: %s", tostring(error));
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