Comparison

plugins/mod_smacks.lua @ 12526:252ed01896dd 0.12 0.12.1

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.
author Kim Alvefur <zash@zash.se>
date Fri, 27 May 2022 14:45:35 +0200
parent 12525:8087f5357f53
child 12527:923d6fe5ee41
child 12549:3729a6bdb562
comparison
equal deleted inserted replaced
12525:8087f5357f53 12526:252ed01896dd
53 local new_id = require "util.id".short; 53 local new_id = require "util.id".short;
54 local watchdog = require "util.watchdog"; 54 local watchdog = require "util.watchdog";
55 local it = require"util.iterators"; 55 local it = require"util.iterators";
56 56
57 local sessionmanager = require "core.sessionmanager"; 57 local sessionmanager = require "core.sessionmanager";
58 local core_process_stanza = prosody.core_process_stanza;
59 58
60 local xmlns_errors = "urn:ietf:params:xml:ns:xmpp-stanzas"; 59 local xmlns_errors = "urn:ietf:params:xml:ns:xmpp-stanzas";
61 local xmlns_delay = "urn:xmpp:delay"; 60 local xmlns_delay = "urn:xmpp:delay";
62 local xmlns_mam2 = "urn:xmpp:mam:2"; 61 local xmlns_mam2 = "urn:xmpp:mam:2";
63 local xmlns_sm2 = "urn:xmpp:sm:2"; 62 local xmlns_sm2 = "urn:xmpp:sm:2";
418 session.outgoing_stanza_queue = nil; 417 session.outgoing_stanza_queue = nil;
419 for stanza in queue._queue:consume() do 418 for stanza in queue._queue:consume() do
420 if not module:fire_event("delivery/failure", { session = session, stanza = stanza }) then 419 if not module:fire_event("delivery/failure", { session = session, stanza = stanza }) then
421 if stanza.attr.type ~= "error" and stanza.attr.from ~= session.full_jid then 420 if stanza.attr.type ~= "error" and stanza.attr.from ~= session.full_jid then
422 local reply = st.error_reply(stanza, "cancel", "recipient-unavailable"); 421 local reply = st.error_reply(stanza, "cancel", "recipient-unavailable");
423 core_process_stanza(session, reply); 422 module:send(reply);
424 end 423 end
425 end 424 end
426 end 425 end
427 end 426 end
428 end 427 end