Software /
code /
prosody
Changeset
2471:2aeb55a51f47
net.xmppserver_listener: Handle stream-error errors from xmlhandlers, and close session in response
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 19 Jan 2010 04:38:43 +0000 |
parents | 2470:2c3f05c01d7c |
children | 2472:cde876604bb7 |
files | net/xmppserver_listener.lua |
diffstat | 1 files changed, 20 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/net/xmppserver_listener.lua Tue Jan 19 04:37:28 2010 +0000 +++ b/net/xmppserver_listener.lua Tue Jan 19 04:38:43 2010 +0000 @@ -20,12 +20,31 @@ 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