Add flag to control max backoff time to connect to the server

This commit is contained in:
Σrebe - Romain GERARD 2024-05-14 08:29:41 +02:00
parent 207ad7480b
commit 562c78187b
No known key found for this signature in database
GPG key ID: 7A42B4B97E0332F4
2 changed files with 6 additions and 1 deletions

View file

@ -47,7 +47,7 @@ tokio = { version = "1.37.0", features = ["full"] }
tokio-stream = { version = "0.1.15", features = ["net"] } tokio-stream = { version = "0.1.15", features = ["net"] }
[target.'cfg(os = "linux")'.dependencies] [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] [target.'cfg(not(os = "linux"))'.dependencies]
tokio-rustls = { version = "0.26.0", default-features = false, features = ["logging", "tls12", "ring"] } tokio-rustls = { version = "0.26.0", default-features = false, features = ["logging", "tls12", "ring"] }

View file

@ -138,6 +138,10 @@ struct Client {
#[arg(short = 'c', long, value_name = "INT", default_value = "0", verbatim_doc_comment)] #[arg(short = 'c', long, value_name = "INT", default_value = "0", verbatim_doc_comment)]
connection_min_idle: u32, 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 /// 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. /// 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 /// or it will be flagged as fishy and your request rejected
@ -891,6 +895,7 @@ async fn main() {
.max_size(1000) .max_size(1000)
.min_idle(Some(args.connection_min_idle)) .min_idle(Some(args.connection_min_idle))
.max_lifetime(Some(Duration::from_secs(30))) .max_lifetime(Some(Duration::from_secs(30)))
.connection_timeout(args.connection_retry_max_backoff_sec)
.retry_connection(true) .retry_connection(true)
.build(client_config.clone()) .build(client_config.clone())
.await .await