From 562c78187b658d724be4d42f2a27c20a1ec61347 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=A3rebe=20-=20Romain=20GERARD?= Date: Tue, 14 May 2024 08:29:41 +0200 Subject: [PATCH] Add flag to control max backoff time to connect to the server --- Cargo.toml | 2 +- src/main.rs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 4cb7ab8..90e43e6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,7 +47,7 @@ tokio = { version = "1.37.0", features = ["full"] } tokio-stream = { version = "0.1.15", features = ["net"] } [target.'cfg(os = "linux")'.dependencies] -tokio-rustls = { version = "0.26.0", features = ["tls12"] } +tokio-rustls = { version = "0.26.0", features = [] } [target.'cfg(not(os = "linux"))'.dependencies] tokio-rustls = { version = "0.26.0", default-features = false, features = ["logging", "tls12", "ring"] } diff --git a/src/main.rs b/src/main.rs index 43f9959..d227dc8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -138,6 +138,10 @@ struct Client { #[arg(short = 'c', long, value_name = "INT", default_value = "0", verbatim_doc_comment)] connection_min_idle: u32, + /// The maximum of time in seconds while we are going to try to connect to the server before failing the connection/tunnel request + #[arg(long, value_name = "DURATION_IN_SECONDS", default_value = "300", value_parser = parse_duration_sec, verbatim_doc_comment)] + connection_retry_max_backoff_sec: Duration, + /// Domain name that will be used as SNI during TLS handshake /// Warning: If you are behind a CDN (i.e: Cloudflare) you must set this domain also in the http HOST header. /// or it will be flagged as fishy and your request rejected @@ -891,6 +895,7 @@ async fn main() { .max_size(1000) .min_idle(Some(args.connection_min_idle)) .max_lifetime(Some(Duration::from_secs(30))) + .connection_timeout(args.connection_retry_max_backoff_sec) .retry_connection(true) .build(client_config.clone()) .await