Skip to content

Commit 0e51eb6

Browse files
authored
feat: Add optional timeout on proxy (env var: RCH__PROXY__TIMEOUT_MS) (#1595)
* feat: Add optional timeout on proxy * chore: 0.11.5 * chore: Move docker compose to rabbitmq/ * fix: docs
1 parent dc68717 commit 0e51eb6

File tree

12 files changed

+22
-33
lines changed

12 files changed

+22
-33
lines changed

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "reacher_backend"
3-
version = "0.11.4"
3+
version = "0.11.5"
44
edition = "2018"
55
license = "AGPL-3.0"
66
publish = false

backend/backend_config.toml

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -62,41 +62,21 @@ webdriver_addr = "http://localhost:9515"
6262
# - RCH__PROXY__PORT
6363
# - RCH__PROXY__USERNAME
6464
# - RCH__PROXY__PASSWORD
65+
# - RCH__PROXY__TIMEOUT_MS
6566
#
6667
# [proxy]
6768
# host = "my.proxy.com"
6869
# port = 1080
6970
# username = "my-username"
7071
# password = "my-password"
72+
# timeout_ms = 30000
7173

7274
[webdriver]
7375
# Path to the Chrome binary. If not set, the default system Chrome will be used.
7476
#
7577
# Env variable: RCH__WEBDRIVER__BINARY
7678
# binary = "/usr/bin/google-chrome"
7779

78-
# Deprecated: use the "proxies" configuration below instead.
79-
#
80-
# Uncomment the lines below to define a proxy called "default". If you want to
81-
# use a proxy, you can set the `proxy` field in the `verif_method` section
82-
# below to "default". Not setting it will NOT apply this default proxy to
83-
# verifications though.
84-
#
85-
# The username and password are optional and only needed if the proxy requires
86-
# authentication.
87-
#
88-
# Env variables:
89-
# - RCH__PROXY__HOST
90-
# - RCH__PROXY__PORT
91-
# - RCH__PROXY__USERNAME
92-
# - RCH__PROXY__PASSWORD
93-
#
94-
# [proxy]
95-
# host = "my.proxy.com"
96-
# port = 1080
97-
# username = "my-username"
98-
# password = "my-password"
99-
10080
# Override verification method to use for each email provider. Each email provider can
10181
# be verified using one of the following methods:
10282
# - Gmail: smtp

cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "check-if-email-exists-cli"
3-
version = "0.11.4"
3+
version = "0.11.5"
44
default-run = "check_if_email_exists"
55
edition = "2018"
66
description = "Check if an email address exists without sending any email."

cli/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ async fn main() -> Result<(), anyhow::Error> {
8484
port: CONF.proxy_port,
8585
username: CONF.proxy_username.clone(),
8686
password: CONF.proxy_password.clone(),
87+
timeout_ms: None,
8788
});
8889
let verif_method = VerifMethod::new_with_same_config_for_all(
8990
proxy,

core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "check-if-email-exists"
3-
version = "0.11.4"
3+
version = "0.11.5"
44
authors = ["Amaury <[email protected]>"]
55
categories = ["email"]
66
description = "Check if an email address exists without sending any email"

core/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
//! host: "my-proxy.io".to_string(), // Use a SOCKS5 proxy to verify the email
5050
//! port: 1080,
5151
//! username: None, // You can also set it non-empty
52-
//! password: None
52+
//! password: None,
53+
//! timeout_ms: None,
5354
//! });
5455
//! let verif_method = VerifMethod {
5556
//! proxies,

core/src/smtp/connect.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ async fn connect_to_smtp_host(
7474

7575
let stream: BufStream<Box<dyn AsyncReadWrite>> = match &verif_method.proxy {
7676
Some(proxy) => {
77+
let mut config = Config::default();
78+
if let Some(timeout_ms) = proxy.timeout_ms {
79+
config.set_connect_timeout(timeout_ms / 1000);
80+
}
81+
7782
let socks_stream =
7883
if let (Some(username), Some(password)) = (&proxy.username, &proxy.password) {
7984
Socks5Stream::connect_with_password(
@@ -82,15 +87,15 @@ async fn connect_to_smtp_host(
8287
verif_method.config.smtp_port,
8388
username.clone(),
8489
password.clone(),
85-
Config::default(),
90+
config,
8691
)
8792
.await?
8893
} else {
8994
Socks5Stream::connect(
9095
(proxy.host.as_ref(), proxy.port),
9196
clean_host.clone(),
9297
verif_method.config.smtp_port,
93-
Config::default(),
98+
config,
9499
)
95100
.await?
96101
};

core/src/util/input_output.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ pub struct CheckEmailInputProxy {
102102
pub username: Option<String>,
103103
/// Password to pass to proxy authentication.
104104
pub password: Option<String>,
105+
/// The timeout for the connection to the proxy, in ms.
106+
pub timeout_ms: Option<u64>,
105107
}
106108

107109
/// Builder pattern for the input argument into the main `email_exists`
File renamed without changes.

0 commit comments

Comments
 (0)