mirror of
https://github.com/chatmail/core.git
synced 2026-05-17 05:46:30 +03:00
imap: add connect() timeouts
This commit is contained in:
@@ -29,6 +29,7 @@
|
|||||||
- Fetch messages in order of their INTERNALDATE (fixes reactions for Gmail f.e.) #3789
|
- Fetch messages in order of their INTERNALDATE (fixes reactions for Gmail f.e.) #3789
|
||||||
- python: do not pass NULL to ffi.gc if the context can't be created #3818
|
- python: do not pass NULL to ffi.gc if the context can't be created #3818
|
||||||
- Add read/write timeouts to IMAP sockets #3820
|
- Add read/write timeouts to IMAP sockets #3820
|
||||||
|
- Add connection timeout to IMAP sockets #3828
|
||||||
|
|
||||||
|
|
||||||
## 1.102.0
|
## 1.102.0
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ use async_imap::Session as ImapSession;
|
|||||||
|
|
||||||
use async_smtp::ServerAddress;
|
use async_smtp::ServerAddress;
|
||||||
use tokio::net::{self, TcpStream};
|
use tokio::net::{self, TcpStream};
|
||||||
|
use tokio::time::timeout;
|
||||||
use tokio_io_timeout::TimeoutStream;
|
use tokio_io_timeout::TimeoutStream;
|
||||||
|
|
||||||
use super::capabilities::Capabilities;
|
use super::capabilities::Capabilities;
|
||||||
@@ -96,7 +97,7 @@ impl Client {
|
|||||||
domain: &str,
|
domain: &str,
|
||||||
strict_tls: bool,
|
strict_tls: bool,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let tcp_stream = TcpStream::connect(addr).await?;
|
let tcp_stream = timeout(IMAP_TIMEOUT, TcpStream::connect(addr)).await??;
|
||||||
let mut timeout_stream = TimeoutStream::new(tcp_stream);
|
let mut timeout_stream = TimeoutStream::new(tcp_stream);
|
||||||
timeout_stream.set_write_timeout(Some(IMAP_TIMEOUT));
|
timeout_stream.set_write_timeout(Some(IMAP_TIMEOUT));
|
||||||
timeout_stream.set_read_timeout(Some(IMAP_TIMEOUT));
|
timeout_stream.set_read_timeout(Some(IMAP_TIMEOUT));
|
||||||
@@ -119,7 +120,7 @@ impl Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn connect_insecure(addr: impl net::ToSocketAddrs) -> Result<Self> {
|
pub async fn connect_insecure(addr: impl net::ToSocketAddrs) -> Result<Self> {
|
||||||
let tcp_stream = TcpStream::connect(addr).await?;
|
let tcp_stream = timeout(IMAP_TIMEOUT, TcpStream::connect(addr)).await??;
|
||||||
let mut timeout_stream = TimeoutStream::new(tcp_stream);
|
let mut timeout_stream = TimeoutStream::new(tcp_stream);
|
||||||
timeout_stream.set_write_timeout(Some(IMAP_TIMEOUT));
|
timeout_stream.set_write_timeout(Some(IMAP_TIMEOUT));
|
||||||
timeout_stream.set_read_timeout(Some(IMAP_TIMEOUT));
|
timeout_stream.set_read_timeout(Some(IMAP_TIMEOUT));
|
||||||
|
|||||||
Reference in New Issue
Block a user