mirror of
https://github.com/mailscope/kumomta.git
synced 2026-09-09 20:12:13 +00:00
This allows tracing incoming SMTP sessions. Sessions are traced through to the cli in realtime. The implementation is via a websocket, which makes this also potentially pluggable into a webui in the future, although care must be taken to ensure that only authorized system operators can enable this, as it can reveal authentication secrets in the traced dialog, as well as the content of messages. This commit doesn't include documentation on the shape of the websocket JSON at this time. refs: https://github.com/KumoCorp/kumomta/issues/44 ``` ; ./target/debug/kcli trace-smtp-server [127.0.0.1:51778->127.0.0.1:2025] === Connected {"received_from":"127.0.0.1:51778","received_via":"127.0.0.1:2025","reception_protocol":"ESMTP"} [127.0.0.1:51778->127.0.0.1:2025] <- 220 foo Welcome to KumoMTA! [127.0.0.1:51778->127.0.0.1:2025] -> EHLO foo.lan [127.0.0.1:51778->127.0.0.1:2025] === smtp_server_ehlo: Ok [127.0.0.1:51778->127.0.0.1:2025] <- 250-foo Aloha foo.lan [127.0.0.1:51778->127.0.0.1:2025] <- 250-PIPELINING [127.0.0.1:51778->127.0.0.1:2025] <- 250-ENHANCEDSTATUSCODES [127.0.0.1:51778->127.0.0.1:2025] <- 250 STARTTLS [127.0.0.1:51778->127.0.0.1:2025] -> STARTTLS [127.0.0.1:51778->127.0.0.1:2025] <- 220 Ready to Start TLS [127.0.0.1:51778->127.0.0.1:2025] -> EHLO foo.lan [127.0.0.1:51778->127.0.0.1:2025] === smtp_server_ehlo: Ok [127.0.0.1:51778->127.0.0.1:2025] <- 250-foo Aloha foo.lan [127.0.0.1:51778->127.0.0.1:2025] <- 250-PIPELINING [127.0.0.1:51778->127.0.0.1:2025] <- 250-ENHANCEDSTATUSCODES [127.0.0.1:51778->127.0.0.1:2025] <- 250 AUTH PLAIN [127.0.0.1:51778->127.0.0.1:2025] -> AUTH PLAIN AHNjb3R0AHRpZ2Vy [127.0.0.1:51778->127.0.0.1:2025] === smtp_server_auth_plain: Ok: Bool(true) [127.0.0.1:51778->127.0.0.1:2025] <- 235 2.7.0 AUTH OK! [127.0.0.1:51778->127.0.0.1:2025] === conn_meta updated to {"authn_id":"scott","authz_id":"scott","received_from":"127.0.0.1:51778","received_via":"127.0.0.1:2025","reception_protocol":"ESMTP"} [127.0.0.1:51778->127.0.0.1:2025] -> MAIL FROM:<wez@example.com> [127.0.0.1:51778->127.0.0.1:2025] === smtp_server_mail_from: Ok [127.0.0.1:51778->127.0.0.1:2025] <- 250 OK EnvelopeAddress(\"wez@example.com\") [127.0.0.1:51778->127.0.0.1:2025] -> RCPT TO:<wez@wezfurlong.org> [127.0.0.1:51778->127.0.0.1:2025] === smtp_server_rcpt_to: Ok [127.0.0.1:51778->127.0.0.1:2025] <- 250 OK EnvelopeAddress(\"wez@wezfurlong.org\") [127.0.0.1:51778->127.0.0.1:2025] -> DATA [127.0.0.1:51778->127.0.0.1:2025] <- 354 Send body; end with CRLF.CRLF [127.0.0.1:51778->127.0.0.1:2025] -> Date: Sun, 13 Aug 2023 10:10:40 -0700 [127.0.0.1:51778->127.0.0.1:2025] -> To: wez@wezfurlong.org [127.0.0.1:51778->127.0.0.1:2025] -> From: wez@example.com [127.0.0.1:51778->127.0.0.1:2025] -> Subject: test Sun, 13 Aug 2023 10:10:40 -0700 [127.0.0.1:51778->127.0.0.1:2025] -> Message-Id: <20230813101040.1426417@foo> [127.0.0.1:51778->127.0.0.1:2025] -> X-Mailer: swaks v20201014.0 jetmore.org/john/code/swaks/ [127.0.0.1:51778->127.0.0.1:2025] -> [127.0.0.1:51778->127.0.0.1:2025] -> This is a test mailing [127.0.0.1:51778->127.0.0.1:2025] -> [127.0.0.1:51778->127.0.0.1:2025] -> [127.0.0.1:51778->127.0.0.1:2025] -> . [127.0.0.1:51778->127.0.0.1:2025] === smtp_server_message_received: Ok [127.0.0.1:51778->127.0.0.1:2025] === Message from=wez@example.com to=wez@wezfurlong.org id=5465de7739fc11ee8af250ebf67f93bd [127.0.0.1:51778->127.0.0.1:2025] === Message queue=wezfurlong.org relay=true log_arf=false log_oob=false [127.0.0.1:51778->127.0.0.1:2025] === Message meta: {"authn_id":"scott","authz_id":"scott","received_from":"127.0.0.1:51778","received_via":"127.0.0.1:2025","reception_protocol":"ESMTP"} [127.0.0.1:51778->127.0.0.1:2025] <- 250 OK ids=5465de7739fc11ee8af250ebf67f93bd [127.0.0.1:51778->127.0.0.1:2025] -> QUIT [127.0.0.1:51778->127.0.0.1:2025] <- 221 So long, and thanks for all the fish! [127.0.0.1:51778->127.0.0.1:2025] === Closed ```