Software /
code /
prosody
Diff
plugins/mod_s2s/mod_s2s.lua @ 10403:3b82e9df5a7a
mod_s2s: Allow passing bounce reason as an util.error object (see #770)
This argument is currently unused in s2smanager.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 08 Nov 2019 23:03:47 +0100 |
parent | 10381:66fa45d24481 |
child | 10421:09b54ad0fdc4 |
line wrap: on
line diff
--- a/plugins/mod_s2s/mod_s2s.lua Fri Nov 08 19:25:57 2019 +0100 +++ b/plugins/mod_s2s/mod_s2s.lua Fri Nov 08 23:03:47 2019 +0100 @@ -29,6 +29,7 @@ local runner = require "util.async".runner; local connect = require "net.connect".connect; local service = require "net.resolvers.service"; +local errors = require "util.error"; local connect_timeout = module:get_option_number("s2s_timeout", 90); local stream_close_timeout = module:get_option_number("s2s_close_timeout", 5); @@ -83,18 +84,24 @@ -- TODO use util.error ? local error_type = "cancel"; local condition = "remote-server-not-found"; + local reason_text; if session.had_stream then -- set when a stream is opened by the remote error_type, condition = "wait", "remote-server-timeout"; end + if errors.is_err(reason) then + error_type, condition, reason_text = reason.type, reason.condition, reason.text; + elseif type(reason) == "string" then + reason_text = reason; + end for i, data in ipairs(sendq) do local reply = data[2]; if reply and not(reply.attr.xmlns) and bouncy_stanzas[reply.name] then reply.attr.type = "error"; reply:tag("error", {type = error_type, by = session.from_host}) :tag(condition, {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}):up(); - if reason then + if reason_text then reply:tag("text", {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}) - :text("Server-to-server connection failed: "..reason):up(); + :text("Server-to-server connection failed: "..reason_text):up(); end core_process_stanza(dummy, reply); end