Comparison

plugins/mod_s2s.lua @ 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
parent 11678:f90a337d81a8
child 11683:41b144a93897
comparison
equal deleted inserted replaced
11681:e270d22b11d9 11682:7843f1ca3b33
524 function stream_callbacks.streamclosed(session, attr) 524 function stream_callbacks.streamclosed(session, attr)
525 -- run _streamclosed in async context 525 -- run _streamclosed in async context
526 session.thread:run({ stream = "closed", attr = attr }); 526 session.thread:run({ stream = "closed", attr = attr });
527 end 527 end
528 528
529 -- Some stream conditions indicate a problem on our end, e.g. that we sent
530 -- something invalid. Those should be investigated. Others are problems or
531 -- events in the remote host that don't affect us, or simply that the
532 -- connection was closed for being idle.
533 local stream_condition_severity = {
534 ["bad-format"] = "warn";
535 ["bad-namespace-prefix"] = "warn";
536 ["conflict"] = "warn";
537 ["connection-timeout"] = "debug";
538 ["host-gone"] = "info";
539 ["host-unknown"] = "info";
540 ["improper-addressing"] = "warn";
541 ["internal-server-error"] = "warn";
542 ["invalid-from"] = "warn";
543 ["invalid-namespace"] = "warn";
544 ["invalid-xml"] = "warn";
545 ["not-authorized"] = "warn";
546 ["not-well-formed"] = "warn";
547 ["policy-violation"] = "warn";
548 ["remote-connection-failed"] = "warn";
549 ["reset"] = "info";
550 ["resource-constraint"] = "info";
551 ["restricted-xml"] = "warn";
552 ["see-other-host"] = "info";
553 ["system-shutdown"] = "info";
554 ["undefined-condition"] = "warn";
555 ["unsupported-encoding"] = "warn";
556 ["unsupported-feature"] = "warn";
557 ["unsupported-stanza-type"] = "warn";
558 ["unsupported-version"] = "warn";
559 }
560
529 function stream_callbacks.error(session, error, data) 561 function stream_callbacks.error(session, error, data)
530 if error == "no-stream" then 562 if error == "no-stream" then
531 session.log("debug", "Invalid opening stream header (%s)", (data:gsub("^([^\1]+)\1", "{%1}"))); 563 session.log("debug", "Invalid opening stream header (%s)", (data:gsub("^([^\1]+)\1", "{%1}")));
532 session:close("invalid-namespace"); 564 session:close("invalid-namespace");
533 elseif error == "parse-error" then 565 elseif error == "parse-error" then
544 if condition ~= "undefined-condition" and text then 576 if condition ~= "undefined-condition" and text then
545 break; 577 break;
546 end 578 end
547 end 579 end
548 text = condition .. (text and (" ("..text..")") or ""); 580 text = condition .. (text and (" ("..text..")") or "");
549 session.log("info", "Session closed by remote with error: %s", text); 581 session.log(stream_condition_severity[condition] or "info", "Session closed by remote with error: %s", text);
550 session:close(nil, text); 582 session:close(nil, text);
551 end 583 end
552 end 584 end
553 585
554 --- Session methods 586 --- Session methods