From 568aa794417fc145a5174767b22195592f1a7fd1 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 27 May 2022 12:05:47 +0200 Subject: mod_smacks: Fix bounce of stanzas directed to full JID on unclean disconnect Fixes #1758 Introduced in 1ea01660c79a In e62025f949f9 to and from was inverted since it changed from acting on a reply to acting on the original stanza (or a clone thereof) Unsure of the purpose of this check, you don't usually send stanzas to your own full JID. Perhaps guarding against routing loops? The check was present in the original commit of mod_smacks, prosody-modules rev 9a7671720dec --- plugins/mod_smacks.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mod_smacks.lua b/plugins/mod_smacks.lua index 33c90ee9..3573d74a 100644 --- a/plugins/mod_smacks.lua +++ b/plugins/mod_smacks.lua @@ -418,7 +418,7 @@ local function handle_unacked_stanzas(session) session.outgoing_stanza_queue = nil; for stanza in queue._queue:consume() do if not module:fire_event("delivery/failure", { session = session, stanza = stanza }) then - if stanza.attr.type ~= "error" and stanza.attr.to ~= session.full_jid then + if stanza.attr.type ~= "error" and stanza.attr.from ~= session.full_jid then local reply = st.error_reply(stanza, "cancel", "recipient-unavailable"); core_process_stanza(session, reply); end -- cgit v1.2.3 From d7e7558bae40e9b28aeba55493439b51ddf506ec Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 27 May 2022 14:45:35 +0200 Subject: mod_smacks: Bounce unhandled stanzas from local origin (fix #1759) Sending stanzas with a remote session as origin when the stanzas have a local JID in the from attribute trips validation in core.stanza_router, leading to warnings: > Received a stanza claiming to be from remote.example, over a stream authed for localhost.example Using module:send() uses the local host as origin, which is fine here. --- plugins/mod_smacks.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/mod_smacks.lua b/plugins/mod_smacks.lua index 3573d74a..35ea0e4f 100644 --- a/plugins/mod_smacks.lua +++ b/plugins/mod_smacks.lua @@ -55,7 +55,6 @@ local watchdog = require "util.watchdog"; local it = require"util.iterators"; local sessionmanager = require "core.sessionmanager"; -local core_process_stanza = prosody.core_process_stanza; local xmlns_errors = "urn:ietf:params:xml:ns:xmpp-stanzas"; local xmlns_delay = "urn:xmpp:delay"; @@ -420,7 +419,7 @@ local function handle_unacked_stanzas(session) if not module:fire_event("delivery/failure", { session = session, stanza = stanza }) then if stanza.attr.type ~= "error" and stanza.attr.from ~= session.full_jid then local reply = st.error_reply(stanza, "cancel", "recipient-unavailable"); - core_process_stanza(session, reply); + module:send(reply); end end end -- cgit v1.2.3