From a545fec355584bd7424cdf59cd3219cda68ebd6f Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 26 Jan 2016 00:28:07 +0100 Subject: mod_c2s, mod_s2s: Lower priority of session shutdown to negative, so that plugins hooking at the default priority run first (fixes #601) --- plugins/mod_c2s.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/mod_c2s.lua') diff --git a/plugins/mod_c2s.lua b/plugins/mod_c2s.lua index 3d6487c9..8524c37e 100644 --- a/plugins/mod_c2s.lua +++ b/plugins/mod_c2s.lua @@ -275,7 +275,7 @@ module:hook("server-stopping", function(event) for _, session in pairs(sessions) do session:close{ condition = "system-shutdown", text = reason }; end -end, 1000); +end, -100); -- cgit v1.2.3 From 38093fa822b28840d68b6490787f565884e5c89b Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 2 Mar 2016 16:28:11 +0100 Subject: mod_c2s: Remove connection object from session object when connection disconnected to prevent accidental use (see #590) --- plugins/mod_c2s.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins/mod_c2s.lua') diff --git a/plugins/mod_c2s.lua b/plugins/mod_c2s.lua index 8524c37e..30a017c0 100644 --- a/plugins/mod_c2s.lua +++ b/plugins/mod_c2s.lua @@ -258,6 +258,7 @@ function listener.ondisconnect(conn, err) if session then (session.log or log)("info", "Client disconnected: %s", err or "connection closed"); sm_destroy_session(session, err); + session.conn = nil; sessions[conn] = nil; end end -- cgit v1.2.3 From 71cd96efa7f28656fd61354755b30f9054c238ea Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 3 Apr 2016 15:18:21 +0200 Subject: mod_c2s: Just destroy the session when it has no connection (see #641) --- plugins/mod_c2s.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'plugins/mod_c2s.lua') diff --git a/plugins/mod_c2s.lua b/plugins/mod_c2s.lua index 30a017c0..2bb919f8 100644 --- a/plugins/mod_c2s.lua +++ b/plugins/mod_c2s.lua @@ -175,6 +175,9 @@ local function session_close(session, reason) sm_destroy_session(session, reason); conn:close(); end + else + local reason = (reason and (reason.name or reason.text or reason.condition)) or reason; + sm_destroy_session(session, reason); end end -- cgit v1.2.3 From 5e0e0d2723d721e3ffc6c1b8f35e8008e91d6786 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 13 Sep 2017 18:18:57 +0200 Subject: mod_c2s: Iterate over child tags instead of child nodes in stream error (fixes traceback from #987) --- plugins/mod_c2s.lua | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'plugins/mod_c2s.lua') diff --git a/plugins/mod_c2s.lua b/plugins/mod_c2s.lua index 2bb919f8..fdb3b211 100644 --- a/plugins/mod_c2s.lua +++ b/plugins/mod_c2s.lua @@ -98,16 +98,14 @@ function stream_callbacks.error(session, error, data) session:close("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 + for child in data:childtags(nil, xmlns_xmpp_streams) do + if child.name ~= "text" then + condition = child.name; + else + text = child:get_text(); + end + if condition ~= "undefined-condition" and text then + break; end end text = condition .. (text and (" ("..text..")") or ""); -- cgit v1.2.3 From bd0478207739d4f7e6ea8db92d3d1b667187a7db Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 25 May 2018 21:09:34 +0200 Subject: mod_c2s: Do not allow the stream 'to' to change across stream restarts (fixes #1147) --- plugins/mod_c2s.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'plugins/mod_c2s.lua') diff --git a/plugins/mod_c2s.lua b/plugins/mod_c2s.lua index fdb3b211..2848f92f 100644 --- a/plugins/mod_c2s.lua +++ b/plugins/mod_c2s.lua @@ -40,12 +40,19 @@ local default_stream_attr = { ["xmlns:stream"] = "http://etherx.jabber.org/strea function stream_callbacks.streamopened(session, attr) local send = session.send; - session.host = nameprep(attr.to); - if not session.host then + local host = nameprep(attr.to); + if not host then session:close{ condition = "improper-addressing", text = "A valid 'to' attribute is required on stream headers" }; return; end + if not session.host then + session.host = host; + elseif session.host ~= host then + session:close{ condition = "not-authorized", + text = "The 'to' attribute must remain the same across stream restarts" }; + return; + end session.version = tonumber(attr.version) or 0; session.streamid = uuid_generate(); (session.log or session)("debug", "Client sent opening to %s", session.host); -- cgit v1.2.3