mirror of
https://github.com/chatmail/core.git
synced 2026-05-01 20:36:31 +03:00
feat: improve logging of connection failures
Previously it was not always clear whether IMAP or SMTP connection failed and what was the endpoint used.
This commit is contained in:
@@ -356,10 +356,10 @@ impl Imap {
|
|||||||
context,
|
context,
|
||||||
self.proxy_config.clone(),
|
self.proxy_config.clone(),
|
||||||
self.strict_tls,
|
self.strict_tls,
|
||||||
connection_candidate,
|
&connection_candidate,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.context("IMAP failed to connect")
|
.with_context(|| format!("IMAP failed to connect to {connection_candidate}"))
|
||||||
{
|
{
|
||||||
Ok(client) => client,
|
Ok(client) => client,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ impl Client {
|
|||||||
Err(err) => {
|
Err(err) => {
|
||||||
warn!(
|
warn!(
|
||||||
context,
|
context,
|
||||||
"Failed to connect to {host} ({resolved_addr}): {err:#}."
|
"IMAP failed to connect to {host} ({resolved_addr}): {err:#}."
|
||||||
);
|
);
|
||||||
Err(err)
|
Err(err)
|
||||||
}
|
}
|
||||||
@@ -161,7 +161,7 @@ impl Client {
|
|||||||
context: &Context,
|
context: &Context,
|
||||||
proxy_config: Option<ProxyConfig>,
|
proxy_config: Option<ProxyConfig>,
|
||||||
strict_tls: bool,
|
strict_tls: bool,
|
||||||
candidate: ConnectionCandidate,
|
candidate: &ConnectionCandidate,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let host = &candidate.host;
|
let host = &candidate.host;
|
||||||
let port = candidate.port;
|
let port = candidate.port;
|
||||||
|
|||||||
@@ -109,8 +109,8 @@ pub(crate) async fn connect_tcp_inner(
|
|||||||
) -> Result<Pin<Box<TimeoutStream<TcpStream>>>> {
|
) -> Result<Pin<Box<TimeoutStream<TcpStream>>>> {
|
||||||
let tcp_stream = timeout(TIMEOUT, TcpStream::connect(addr))
|
let tcp_stream = timeout(TIMEOUT, TcpStream::connect(addr))
|
||||||
.await
|
.await
|
||||||
.context("connection timeout")?
|
.context("Connection timeout")?
|
||||||
.context("connection failure")?;
|
.context("Connection failure")?;
|
||||||
|
|
||||||
// Disable Nagle's algorithm.
|
// Disable Nagle's algorithm.
|
||||||
tcp_stream.set_nodelay(true)?;
|
tcp_stream.set_nodelay(true)?;
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ async fn connection_attempt(
|
|||||||
Err(err) => {
|
Err(err) => {
|
||||||
warn!(
|
warn!(
|
||||||
context,
|
context,
|
||||||
"Failed to connect to {host} ({resolved_addr}): {err:#}."
|
"SMTP failed to connect to {host} ({resolved_addr}): {err:#}."
|
||||||
);
|
);
|
||||||
Err(err)
|
Err(err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user