aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-07-28 19:15:29 +0100
committerMatthew Wild <mwild1@gmail.com>2009-07-28 19:15:29 +0100
commit8ad65c2824d2ee3bd52175df34fdd7bd9d393231 (patch)
tree573edbcc178ff74951f07cb33afbad54371fbf21
parent9e4f7f3b3aff49a164f94b074a7eb8b7cce98aeb (diff)
downloadprosody-8ad65c2824d2ee3bd52175df34fdd7bd9d393231.tar.gz
prosody-8ad65c2824d2ee3bd52175df34fdd7bd9d393231.zip
xmpp{client,server,component]_listener: Open stream if sending an error and it isn't already open. Fixes #120
-rw-r--r--net/xmppclient_listener.lua5
-rw-r--r--net/xmppcomponent_listener.lua5
-rw-r--r--net/xmppserver_listener.lua5
3 files changed, 15 insertions, 0 deletions
diff --git a/net/xmppclient_listener.lua b/net/xmppclient_listener.lua
index 35838692..ce7788c7 100644
--- a/net/xmppclient_listener.lua
+++ b/net/xmppclient_listener.lua
@@ -69,9 +69,14 @@ end
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);
diff --git a/net/xmppcomponent_listener.lua b/net/xmppcomponent_listener.lua
index e62bb810..36d74579 100644
--- a/net/xmppcomponent_listener.lua
+++ b/net/xmppcomponent_listener.lua
@@ -87,9 +87,14 @@ end
--- 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);
diff --git a/net/xmppserver_listener.lua b/net/xmppserver_listener.lua
index 3cfcfe86..81d26526 100644
--- a/net/xmppserver_listener.lua
+++ b/net/xmppserver_listener.lua
@@ -69,9 +69,14 @@ end
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);