diff --git a/crates/kumo-log-types/src/lib.rs b/crates/kumo-log-types/src/lib.rs index 7f442331..15540c55 100644 --- a/crates/kumo-log-types/src/lib.rs +++ b/crates/kumo-log-types/src/lib.rs @@ -18,6 +18,12 @@ pub struct ResolvedAddress { pub addr: IpAddr, } +impl std::fmt::Display for ResolvedAddress { + fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(fmt, "{}/{}", self.name, self.addr) + } +} + #[derive(Serialize, Deserialize, Debug, Copy, Clone, Eq, PartialEq, Hash, Ord, PartialOrd)] pub enum RecordType { /// Recorded by a receiving listener diff --git a/crates/kumod/src/smtp_dispatcher.rs b/crates/kumod/src/smtp_dispatcher.rs index 41d95d93..4e69f43a 100644 --- a/crates/kumod/src/smtp_dispatcher.rs +++ b/crates/kumod/src/smtp_dispatcher.rs @@ -179,7 +179,7 @@ impl SmtpDispatcher { detail: 4, }), content: format!( - "{addr:?} is on the list of prohibited_hosts {:?}", + "{addr} is on the list of prohibited_hosts {:?}", path_config.prohibited_hosts ), command: None, @@ -276,10 +276,10 @@ impl SmtpDispatcher { .egress_source .remote_port .unwrap_or(path_config.smtp_port); - let connect_context = format!("connect to {address:?} port {port} and read initial banner"); + let connect_context = format!("connect to {address} port {port} and read initial banner"); self.tracer.diagnostic(Level::INFO, || { - format!("Attempting connection to {address:?} port {port}") + format!("Attempting connection to {address} port {port}") }); let make_connection = { @@ -301,7 +301,7 @@ impl SmtpDispatcher { .await?; tracing::debug!( - "connected to {address:?} port {port} via source address {source_address:?}" + "connected to {address} port {port} via source address {source_address:?}" ); let mut client = SmtpClient::with_stream(stream, &mx_host, timeouts); @@ -341,7 +341,7 @@ impl SmtpDispatcher { let pretls_caps = client .ehlo(&ehlo_name) .await - .with_context(|| format!("{address:?}:{port}: EHLO after banner"))?; + .with_context(|| format!("{address}:{port}: EHLO after banner"))?; // Use STARTTLS if available. let has_tls = pretls_caps.contains_key("STARTTLS"); @@ -493,7 +493,7 @@ impl SmtpDispatcher { { TlsStatus::FailedHandshake(handshake_error) => { tracing::debug!( - "TLS handshake with {address:?}:{port} failed: \ + "TLS handshake with {address}:{port} failed: \ {handshake_error}, but continuing in clear text because \ we are in OpportunisticInsecure mode" ); @@ -518,7 +518,7 @@ impl SmtpDispatcher { self.remember_broken_tls(&dispatcher.name, &path_config); OpportunisticInsecureTlsHandshakeError { error, - address: format!("{address:?}:{port}"), + address: format!("{address}:{port}"), label, } })?; diff --git a/docs/changelog/main.md b/docs/changelog/main.md index 0a43887f..cbac1ded 100644 --- a/docs/changelog/main.md +++ b/docs/changelog/main.md @@ -10,6 +10,11 @@ * Updated embedded libunbound to 1.22 +* Use more compact representation of ResolvedAddress in logs. Instead of + showing something like `ResolvedAddress { name: "some.host.", addr: 10.0.0.1 }` + we now display it as `some.host./10.0.0.1` which is a bit easier to + understand and occupies less space in the logs. + ## Fixes * When `enable_tls` is set to `Required` or `RequiredInsecure`, ignore the