aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-11-08 23:03:47 +0100
committerKim Alvefur <zash@zash.se>2019-11-08 23:03:47 +0100
commit6666a4c8147fd5ba7e58fdc0fef64e8c0ff83be3 (patch)
tree56e66377e8e58b52e1390850777147bd98477845 /plugins
parentc900a5c54439d358628540fbb697d41303b28d10 (diff)
downloadprosody-6666a4c8147fd5ba7e58fdc0fef64e8c0ff83be3.tar.gz
prosody-6666a4c8147fd5ba7e58fdc0fef64e8c0ff83be3.zip
mod_s2s: Allow passing bounce reason as an util.error object (see #770)
This argument is currently unused in s2smanager.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_s2s/mod_s2s.lua11
1 files changed, 9 insertions, 2 deletions
diff --git a/plugins/mod_s2s/mod_s2s.lua b/plugins/mod_s2s/mod_s2s.lua
index 42998c30..9db13cb7 100644
--- a/plugins/mod_s2s/mod_s2s.lua
+++ b/plugins/mod_s2s/mod_s2s.lua
@@ -29,6 +29,7 @@ local fire_global_event = prosody.events.fire_event;
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 @@ local function bounce_sendq(session, reason)
-- 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