Software /
code /
prosody
Changeset
1617:c6e175a0d83b
xmpp{client,server,component]_listener: Open stream if sending an error and it isn't already open. Fixes #120
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 28 Jul 2009 19:15:29 +0100 |
parents | 1616:80ea744f2643 |
children | 1618:ba2a92230b77 1619:ae3250783db2 |
files | net/xmppclient_listener.lua net/xmppcomponent_listener.lua net/xmppserver_listener.lua |
diffstat | 3 files changed, 15 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/net/xmppclient_listener.lua Tue Jul 28 18:47:59 2009 +0100 +++ b/net/xmppclient_listener.lua Tue Jul 28 19:15:29 2009 +0100 @@ -69,9 +69,14 @@ local stream_xmlns_attr = {xmlns='urn:ietf:params:xml:ns:xmpp-streams'}; +local default_stream_attr = { ["xmlns:stream"] = stream_callbacks.stream_tag:gsub("%|[^|]+$", ""), xmlns = stream_callbacks.default_ns, version = "1.0", id = "" }; local function session_close(session, reason) local log = session.log or log; if session.conn then + if session.notopen then + session.send("<?xml version='1.0'?>"); + session.send(st.stanza("stream:stream", default_stream_attr):top_tag()); + end if reason then if type(reason) == "string" then -- assume stream error log("info", "Disconnecting client, <stream:error> is: %s", reason);
--- a/net/xmppcomponent_listener.lua Tue Jul 28 18:47:59 2009 +0100 +++ b/net/xmppcomponent_listener.lua Tue Jul 28 19:15:29 2009 +0100 @@ -87,9 +87,14 @@ --- Closing a component connection local stream_xmlns_attr = {xmlns='urn:ietf:params:xml:ns:xmpp-streams'}; +local default_stream_attr = { ["xmlns:stream"] = stream_callbacks.stream_tag:gsub("%|[^|]+$", ""), xmlns = stream_callbacks.default_ns, version = "1.0", id = "" }; local function session_close(session, reason) local log = session.log or log; if session.conn then + if session.notopen then + session.send("<?xml version='1.0'?>"); + session.send(st.stanza("stream:stream", default_stream_attr):top_tag()); + end if reason then if type(reason) == "string" then -- assume stream error log("info", "Disconnecting component, <stream:error> is: %s", reason);
--- a/net/xmppserver_listener.lua Tue Jul 28 18:47:59 2009 +0100 +++ b/net/xmppserver_listener.lua Tue Jul 28 19:15:29 2009 +0100 @@ -69,9 +69,14 @@ local stream_xmlns_attr = {xmlns='urn:ietf:params:xml:ns:xmpp-streams'}; +local default_stream_attr = { ["xmlns:stream"] = stream_callbacks.stream_tag:gsub("%|[^|]+$", ""), xmlns = stream_callbacks.default_ns, version = "1.0", id = "" }; local function session_close(session, reason) local log = session.log or log; if session.conn then + if session.notopen then + session.sends2s("<?xml version='1.0'?>"); + session.sends2s(st.stanza("stream:stream", default_stream_attr):top_tag()); + end if reason then if type(reason) == "string" then -- assume stream error log("info", "Disconnecting %s[%s], <stream:error> is: %s", session.host or "(unknown host)", session.type, reason);