Mercurial > prosody-hg
comparison plugins/mod_s2s.lua @ 14021:d4a7cc295363
mod_s2s: Report outgoing connection failures to remote servers
When setting up a new server, it can be easy to make mistakes with DNS,
firewall or port forwarding that results in the ability to make outgoing
connections, but not receive incoming, leading to a half-working setup
where messages can be sent but not received. This can be difficult to
diagnose. It is also difficult to inform the other end about the problem
without a working channel in that direction, but when an incoming
connection has been established, it can be closed with a stream error,
which hopefully shows up in logs.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Tue, 30 Dec 2025 17:45:58 +0100 |
| parents | 4067a95336dd |
| children | e08e535a9945 |
comparison
equal
deleted
inserted
replaced
| 14020:3c2bfa6a69df | 14021:d4a7cc295363 |
|---|---|
| 1078 end | 1078 end |
| 1079 end | 1079 end |
| 1080 | 1080 |
| 1081 module:hook("s2s-check-certificate", check_auth_policy, -1); | 1081 module:hook("s2s-check-certificate", check_auth_policy, -1); |
| 1082 | 1082 |
| 1083 -- When an outgoing connection fails, close a corresponding incoming connection with a stream error to indicate the problem to the remote | |
| 1084 module:hook("s2s-destroyed", function(event) | |
| 1085 local s2sout = event.session; | |
| 1086 if s2sout.type ~= "s2sout_unauthed" then return end | |
| 1087 for s2sin in pairs(prosody.incoming_s2s) do | |
| 1088 if s2sin.from_host == s2sout.to_host and s2sin.to_host == s2sout.from_host then | |
| 1089 s2sin:close(errors.new({ condition = "reset", text = "Could not deliver return stanzas, please check your DNS and firewall" })); | |
| 1090 end | |
| 1091 end | |
| 1092 end); | |
| 1093 | |
| 1083 module:hook("server-stopping", function(event) | 1094 module:hook("server-stopping", function(event) |
| 1084 -- Close ports | 1095 -- Close ports |
| 1085 local pm = require "prosody.core.portmanager"; | 1096 local pm = require "prosody.core.portmanager"; |
| 1086 for _, netservice in pairs(module.items["net-provider"]) do | 1097 for _, netservice in pairs(module.items["net-provider"]) do |
| 1087 pm.unregister_service(netservice.name, netservice); | 1098 pm.unregister_service(netservice.name, netservice); |
