# HG changeset patch # User Kim Alvefur # Date 1574468943 -3600 # Node ID 42cf93ff4618fc00ee5b529ccaaa32662624d0e2 # Parent e7d3fa49495faeb3de8d32b62d0bf4f3181262c6 s2s: Allow passing a custom error for bouncing queued stanzas (#770) Since stream errors and stanza errors are different diff -r e7d3fa49495f -r 42cf93ff4618 core/s2smanager.lua --- a/core/s2smanager.lua Wed Nov 20 21:31:46 2019 +0100 +++ b/core/s2smanager.lua Sat Nov 23 01:29:03 2019 +0100 @@ -84,14 +84,14 @@ return setmetatable(session, resting_session); end -local function destroy_session(session, reason) +local function destroy_session(session, reason, bounce_reason) if session.destroyed then return; end local log = session.log or log; log("debug", "Destroying %s session %s->%s%s%s", session.direction, session.from_host, session.to_host, reason and ": " or "", reason or ""); if session.direction == "outgoing" then hosts[session.from_host].s2sout[session.to_host] = nil; - session:bounce_sendq(reason); + session:bounce_sendq(bounce_reason or reason); elseif session.direction == "incoming" then if session.outgoing then hosts[session.to_host].s2sout[session.from_host] = nil; diff -r e7d3fa49495f -r 42cf93ff4618 plugins/mod_s2s/mod_s2s.lua --- a/plugins/mod_s2s/mod_s2s.lua Wed Nov 20 21:31:46 2019 +0100 +++ b/plugins/mod_s2s/mod_s2s.lua Sat Nov 23 01:29:03 2019 +0100 @@ -487,7 +487,7 @@ --- Session methods local stream_xmlns_attr = {xmlns='urn:ietf:params:xml:ns:xmpp-streams'}; -local function session_close(session, reason, remote_reason) +local function session_close(session, reason, remote_reason, bounce_reason) local log = session.log or log; if session.conn then if session.notopen then @@ -537,12 +537,12 @@ add_task(stream_close_timeout, function () if not session.destroyed then session.log("warn", "Failed to receive a stream close response, closing connection anyway..."); - s2s_destroy_session(session, reason); + s2s_destroy_session(session, reason, bounce_reason); conn:close(); end end); else - s2s_destroy_session(session, reason); + s2s_destroy_session(session, reason, bounce_reason); conn:close(); -- Close immediately, as this is an outgoing connection or is not authed end end