Software /
code /
prosody
Changeset
11682:7843f1ca3b33
mod_s2s: Vary log level by remote stream error
Increases log level for stream conditions that could indicate a problem
on our end, especially programming errors like invalid XML, or the
remote server saying that our certificate is invalid, since these should
be investigated.
Non-issues like closing of idle streams are lowered to debug since it's
mostly noise.
Other issues left at info are mostly about changes to the remote server,
e.g. complete or partial shutdown.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 14 Jul 2021 02:41:15 +0200 |
parents | 11681:e270d22b11d9 |
children | 11683:41b144a93897 |
files | plugins/mod_s2s.lua |
diffstat | 1 files changed, 33 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_s2s.lua Tue Jul 13 23:28:49 2021 +0200 +++ b/plugins/mod_s2s.lua Wed Jul 14 02:41:15 2021 +0200 @@ -526,6 +526,38 @@ session.thread:run({ stream = "closed", attr = attr }); end +-- Some stream conditions indicate a problem on our end, e.g. that we sent +-- something invalid. Those should be investigated. Others are problems or +-- events in the remote host that don't affect us, or simply that the +-- connection was closed for being idle. +local stream_condition_severity = { + ["bad-format"] = "warn"; + ["bad-namespace-prefix"] = "warn"; + ["conflict"] = "warn"; + ["connection-timeout"] = "debug"; + ["host-gone"] = "info"; + ["host-unknown"] = "info"; + ["improper-addressing"] = "warn"; + ["internal-server-error"] = "warn"; + ["invalid-from"] = "warn"; + ["invalid-namespace"] = "warn"; + ["invalid-xml"] = "warn"; + ["not-authorized"] = "warn"; + ["not-well-formed"] = "warn"; + ["policy-violation"] = "warn"; + ["remote-connection-failed"] = "warn"; + ["reset"] = "info"; + ["resource-constraint"] = "info"; + ["restricted-xml"] = "warn"; + ["see-other-host"] = "info"; + ["system-shutdown"] = "info"; + ["undefined-condition"] = "warn"; + ["unsupported-encoding"] = "warn"; + ["unsupported-feature"] = "warn"; + ["unsupported-stanza-type"] = "warn"; + ["unsupported-version"] = "warn"; +} + function stream_callbacks.error(session, error, data) if error == "no-stream" then session.log("debug", "Invalid opening stream header (%s)", (data:gsub("^([^\1]+)\1", "{%1}"))); @@ -546,7 +578,7 @@ end end text = condition .. (text and (" ("..text..")") or ""); - session.log("info", "Session closed by remote with error: %s", text); + session.log(stream_condition_severity[condition] or "info", "Session closed by remote with error: %s", text); session:close(nil, text); end end