From 6d3fb4472d03fa9e71f60689847f1ee03ee2de10 Mon Sep 17 00:00:00 2001 From: link2xt Date: Sun, 20 Oct 2024 07:38:49 +0000 Subject: [PATCH] fix: call update_connection_history for proxified connections --- src/imap/client.rs | 1 + src/net.rs | 8 ++++++++ src/smtp/connect.rs | 1 + 3 files changed, 10 insertions(+) diff --git a/src/imap/client.rs b/src/imap/client.rs index ea23c9fb6d..9bcc448909 100644 --- a/src/imap/client.rs +++ b/src/imap/client.rs @@ -180,6 +180,7 @@ impl Client { Client::connect_insecure_proxy(context, host, port, proxy_config).await? } }; + update_connection_history(context, "imap", host, port, host, time()).await?; Ok(client) } else { let load_cache = match security { diff --git a/src/net.rs b/src/net.rs index 20016d3f63..1ad85a3ea5 100644 --- a/src/net.rs +++ b/src/net.rs @@ -47,6 +47,14 @@ pub(crate) async fn prune_connection_history(context: &Context) -> Result<()> { Ok(()) } +/// Update the timestamp of the last successfull connection +/// to the given `host` and `port` +/// with the given application protocol `alpn`. +/// +/// `addr` is the string representation of IP address. +/// If connection is made over a proxy which does +/// its own DNS resolution, +/// `addr` should be the same as `host`. pub(crate) async fn update_connection_history( context: &Context, alpn: &str, diff --git a/src/smtp/connect.rs b/src/smtp/connect.rs index 742b5269fd..5652d14272 100644 --- a/src/smtp/connect.rs +++ b/src/smtp/connect.rs @@ -168,6 +168,7 @@ async fn connect_stream( connect_insecure_proxy(context, host, port, proxy_config.clone()).await? } }; + update_connection_history(context, "smtp", host, port, host, time()).await?; Ok(stream) } else { let load_cache = match security {