Software /
code /
prosody
Comparison
plugins/mod_s2s/mod_s2s.lua @ 10115:c0bd5daa9c7f
mod_s2s: Distinguish between high and low level errors in bounces
`remote-server-not-found` is reported for problems occurring without a
reply `<stream>` having been opened, e.g. DNS records were not found or
no TCP stream could be established to a functioning XMPP entity.
`remote-server-timeout` is reported for problems that occurring after a
stream has been opened, such as configuration problems, inability to
perform TLS or unsuccessful certificate validation.
Related: #770
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 01 Aug 2019 05:25:34 +0200 |
parent | 10111:0f335815244f |
child | 10120:756b8821007a |
comparison
equal
deleted
inserted
replaced
10114:2f7628804db6 | 10115:c0bd5daa9c7f |
---|---|
75 dummy = true; | 75 dummy = true; |
76 close = function () | 76 close = function () |
77 (session.log or log)("error", "Attempting to close the dummy origin of s2s error replies, please report this! Traceback: %s", traceback()); | 77 (session.log or log)("error", "Attempting to close the dummy origin of s2s error replies, please report this! Traceback: %s", traceback()); |
78 end; | 78 end; |
79 }; | 79 }; |
80 -- FIXME Allow for more specific error conditions | |
81 -- TODO use util.error ? | |
82 local error_type = "cancel"; | |
83 local condition = "remote-server-not-found"; | |
84 if session.had_stream then -- set when a stream is opened by the remote | |
85 error_type, condition = "wait", "remote-server-timeout"; | |
86 end | |
80 for i, data in ipairs(sendq) do | 87 for i, data in ipairs(sendq) do |
81 local reply = data[2]; | 88 local reply = data[2]; |
82 if reply and not(reply.attr.xmlns) and bouncy_stanzas[reply.name] then | 89 if reply and not(reply.attr.xmlns) and bouncy_stanzas[reply.name] then |
83 reply.attr.type = "error"; | 90 reply.attr.type = "error"; |
84 reply:tag("error", {type = "cancel", by = session.from_host}) | 91 reply:tag("error", {type = error_type, by = session.from_host}) |
85 :tag("remote-server-not-found", {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}):up(); | 92 :tag(condition, {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}):up(); |
86 if reason then | 93 if reason then |
87 reply:tag("text", {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}) | 94 reply:tag("text", {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}) |
88 :text("Server-to-server connection failed: "..reason):up(); | 95 :text("Server-to-server connection failed: "..reason):up(); |
89 end | 96 end |
90 core_process_stanza(dummy, reply); | 97 core_process_stanza(dummy, reply); |
299 session.thread:run({ attr = attr }); | 306 session.thread:run({ attr = attr }); |
300 end | 307 end |
301 | 308 |
302 function stream_callbacks._streamopened(session, attr) | 309 function stream_callbacks._streamopened(session, attr) |
303 session.version = tonumber(attr.version) or 0; | 310 session.version = tonumber(attr.version) or 0; |
311 session.had_stream = true; -- Had a stream opened at least once | |
304 | 312 |
305 -- TODO: Rename session.secure to session.encrypted | 313 -- TODO: Rename session.secure to session.encrypted |
306 if session.secure == false then | 314 if session.secure == false then |
307 session.secure = true; | 315 session.secure = true; |
308 session.encrypted = true; | 316 session.encrypted = true; |