Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions wstunnel/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,20 @@ pub struct Client {
))]
pub connection_retry_max_backoff: Duration,

/// Timeout used when establishing connections for tunnel traffic.
/// This includes connecting to the wstunnel server and reverse tunnel endpoint connects.
/// For reverse SOCKS5, client/server values can differ; the shorter side effectively limits wait time.
#[cfg_attr(feature = "clap", arg(
long,
value_name = "DURATION(s|m|h)",
default_value = "3s",
value_parser = parsers::parse_duration_sec,
alias = "timeout-connect-sec",
env = "WSTUNNEL_TIMEOUT_CONNECT",
verbatim_doc_comment
))]
pub timeout_connect: Duration,

/// When using reverse tunnel, the client will try to always keep a connection to the server to await for new tunnels
/// This delay is the maximum of time the client will wait before trying to reconnect to the server in case of failure.
/// The client follows an exponential backoff strategy until it reaches this maximum delay
Expand Down Expand Up @@ -301,6 +315,19 @@ pub struct Server {
#[cfg_attr(feature = "clap", arg(long, default_value = "false", verbatim_doc_comment))]
pub websocket_mask_frame: bool,

/// Timeout used when establishing upstream connections and waiting for reverse SOCKS5 connect handshakes.
/// For reverse SOCKS5, client/server values can differ; the shorter side effectively limits wait time.
#[cfg_attr(feature = "clap", arg(
long,
value_name = "DURATION(s|m|h)",
default_value = "3s",
value_parser = parsers::parse_duration_sec,
alias = "timeout-connect-sec",
env = "WSTUNNEL_TIMEOUT_CONNECT",
verbatim_doc_comment
))]
pub timeout_connect: Duration,

/// Dns resolver to use to lookup ips of domain name
/// This option is not going to work if you use transparent proxy
/// Can be specified multiple time
Expand Down
4 changes: 2 additions & 2 deletions wstunnel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ pub async fn create_client(
http_headers: args.http_headers.into_iter().filter(|(k, _)| k != HOST).collect(),
http_headers_file: args.http_headers_file,
http_header_host: host_header,
timeout_connect: Duration::from_secs(10),
timeout_connect: args.timeout_connect,
websocket_ping_frequency: args
.websocket_ping_frequency
.or(Some(Duration::from_secs(30)))
Expand Down Expand Up @@ -555,7 +555,7 @@ async fn run_server_impl(args: Server, executor: impl TokioExecutorRef) -> anyho
.websocket_ping_frequency
.or(Some(Duration::from_secs(30)))
.filter(|d| d.as_secs() > 0),
timeout_connect: Duration::from_secs(10),
timeout_connect: args.timeout_connect,
websocket_mask_frame: args.websocket_mask_frame,
tls: tls_config,
dns_resolver: DnsResolver::new_from_urls(
Expand Down
Loading
Loading