Compare commits
1
Commits
0166fb6511
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f1d04fcaf |
Generated
+1
@@ -1293,6 +1293,7 @@ dependencies = [
|
|||||||
"http-body-util",
|
"http-body-util",
|
||||||
"hyper",
|
"hyper",
|
||||||
"hyper-util",
|
"hyper-util",
|
||||||
|
"libc",
|
||||||
"rand",
|
"rand",
|
||||||
"rcgen",
|
"rcgen",
|
||||||
"rustls",
|
"rustls",
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ sha2 = "0.10"
|
|||||||
bytes = "1"
|
bytes = "1"
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
url = "2"
|
url = "2"
|
||||||
|
libc = "0.2"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempfile = "3"
|
tempfile = "3"
|
||||||
|
|||||||
+52
@@ -55,6 +55,34 @@ pub enum Commands {
|
|||||||
/// Skip TLS certificate verification (insecure — for DPI/intercepted environments only)
|
/// Skip TLS certificate verification (insecure — for DPI/intercepted environments only)
|
||||||
#[arg(long, default_value = "false")]
|
#[arg(long, default_value = "false")]
|
||||||
insecure_skip_tls_verify: bool,
|
insecure_skip_tls_verify: bool,
|
||||||
|
|
||||||
|
/// Target process file descriptor limit to request on Unix
|
||||||
|
#[arg(long, default_value_t = 1_048_576)]
|
||||||
|
max_open_files: u64,
|
||||||
|
|
||||||
|
/// Maximum concurrent authenticated HTTPS tunnel sessions
|
||||||
|
#[arg(long, default_value_t = 4096)]
|
||||||
|
max_tunnel_sessions: usize,
|
||||||
|
|
||||||
|
/// Maximum concurrent SOCKS5 client connections
|
||||||
|
#[arg(long, default_value_t = 65_536)]
|
||||||
|
max_socks_connections: usize,
|
||||||
|
|
||||||
|
/// Maximum concurrent streams per tunnel
|
||||||
|
#[arg(long, default_value_t = 65_536)]
|
||||||
|
max_streams_per_tunnel: usize,
|
||||||
|
|
||||||
|
/// TLS/HTTP/SOCKS handshake timeout in milliseconds
|
||||||
|
#[arg(long, default_value_t = 10_000)]
|
||||||
|
handshake_timeout_ms: u64,
|
||||||
|
|
||||||
|
/// DNS/target connect timeout in milliseconds
|
||||||
|
#[arg(long, default_value_t = 10_000)]
|
||||||
|
connect_timeout_ms: u64,
|
||||||
|
|
||||||
|
/// Timeout waiting for tunneled CONNECT replies in milliseconds
|
||||||
|
#[arg(long, default_value_t = 15_000)]
|
||||||
|
stream_open_timeout_ms: u64,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// Connect to the HTTPS tunnel listener
|
/// Connect to the HTTPS tunnel listener
|
||||||
@@ -102,6 +130,30 @@ pub enum Commands {
|
|||||||
/// Skip TLS certificate verification (insecure — for DPI/intercepted environments only)
|
/// Skip TLS certificate verification (insecure — for DPI/intercepted environments only)
|
||||||
#[arg(long, default_value = "false")]
|
#[arg(long, default_value = "false")]
|
||||||
insecure_skip_tls_verify: bool,
|
insecure_skip_tls_verify: bool,
|
||||||
|
|
||||||
|
/// Target process file descriptor limit to request on Unix
|
||||||
|
#[arg(long, default_value_t = 1_048_576)]
|
||||||
|
max_open_files: u64,
|
||||||
|
|
||||||
|
/// Maximum concurrent SOCKS5 client connections
|
||||||
|
#[arg(long, default_value_t = 65_536)]
|
||||||
|
max_socks_connections: usize,
|
||||||
|
|
||||||
|
/// Maximum concurrent streams per tunnel
|
||||||
|
#[arg(long, default_value_t = 65_536)]
|
||||||
|
max_streams_per_tunnel: usize,
|
||||||
|
|
||||||
|
/// TLS/HTTP/SOCKS handshake timeout in milliseconds
|
||||||
|
#[arg(long, default_value_t = 10_000)]
|
||||||
|
handshake_timeout_ms: u64,
|
||||||
|
|
||||||
|
/// DNS/target connect timeout in milliseconds
|
||||||
|
#[arg(long, default_value_t = 10_000)]
|
||||||
|
connect_timeout_ms: u64,
|
||||||
|
|
||||||
|
/// Timeout waiting for tunneled CONNECT replies in milliseconds
|
||||||
|
#[arg(long, default_value_t = 15_000)]
|
||||||
|
stream_open_timeout_ms: u64,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// Generate local certificate and auth material
|
/// Generate local certificate and auth material
|
||||||
|
|||||||
@@ -268,7 +268,6 @@ impl FrameWriter {
|
|||||||
) -> Result<(), FrameError> {
|
) -> Result<(), FrameError> {
|
||||||
let bytes = frame.serialize();
|
let bytes = frame.serialize();
|
||||||
writer.write_all(&bytes).await?;
|
writer.write_all(&bytes).await?;
|
||||||
writer.flush().await?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+83
-1
@@ -13,12 +13,15 @@ mod tunnel;
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::process;
|
use std::process;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
use crate::cli::Cli;
|
use crate::cli::Cli;
|
||||||
use crate::connkey::ConnectionKey;
|
use crate::connkey::ConnectionKey;
|
||||||
use crate::tunnel::{ClientTlsMaterial, ConnectorConfig, ListenerConfig, ServerTlsMaterial};
|
use crate::tunnel::{
|
||||||
|
ClientTlsMaterial, ConnectorConfig, ListenerConfig, PerformanceConfig, ServerTlsMaterial,
|
||||||
|
};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// Install the default crypto provider (ring) for rustls
|
// Install the default crypto provider (ring) for rustls
|
||||||
@@ -47,6 +50,13 @@ fn main() {
|
|||||||
auth_token,
|
auth_token,
|
||||||
auth_token_file,
|
auth_token_file,
|
||||||
insecure_skip_tls_verify,
|
insecure_skip_tls_verify,
|
||||||
|
max_open_files,
|
||||||
|
max_tunnel_sessions,
|
||||||
|
max_socks_connections,
|
||||||
|
max_streams_per_tunnel,
|
||||||
|
handshake_timeout_ms,
|
||||||
|
connect_timeout_ms,
|
||||||
|
stream_open_timeout_ms,
|
||||||
} => run_listen(
|
} => run_listen(
|
||||||
listen,
|
listen,
|
||||||
advertise,
|
advertise,
|
||||||
@@ -58,6 +68,13 @@ fn main() {
|
|||||||
auth_token,
|
auth_token,
|
||||||
auth_token_file,
|
auth_token_file,
|
||||||
insecure_skip_tls_verify,
|
insecure_skip_tls_verify,
|
||||||
|
max_open_files,
|
||||||
|
max_tunnel_sessions,
|
||||||
|
max_socks_connections,
|
||||||
|
max_streams_per_tunnel,
|
||||||
|
handshake_timeout_ms,
|
||||||
|
connect_timeout_ms,
|
||||||
|
stream_open_timeout_ms,
|
||||||
),
|
),
|
||||||
crate::cli::Commands::Connect {
|
crate::cli::Commands::Connect {
|
||||||
connection_key_arg,
|
connection_key_arg,
|
||||||
@@ -70,6 +87,12 @@ fn main() {
|
|||||||
auth_token,
|
auth_token,
|
||||||
auth_token_file,
|
auth_token_file,
|
||||||
insecure_skip_tls_verify,
|
insecure_skip_tls_verify,
|
||||||
|
max_open_files,
|
||||||
|
max_socks_connections,
|
||||||
|
max_streams_per_tunnel,
|
||||||
|
handshake_timeout_ms,
|
||||||
|
connect_timeout_ms,
|
||||||
|
stream_open_timeout_ms,
|
||||||
} => run_connect(
|
} => run_connect(
|
||||||
connection_key_arg,
|
connection_key_arg,
|
||||||
target,
|
target,
|
||||||
@@ -81,6 +104,12 @@ fn main() {
|
|||||||
auth_token,
|
auth_token,
|
||||||
auth_token_file,
|
auth_token_file,
|
||||||
insecure_skip_tls_verify,
|
insecure_skip_tls_verify,
|
||||||
|
max_open_files,
|
||||||
|
max_socks_connections,
|
||||||
|
max_streams_per_tunnel,
|
||||||
|
handshake_timeout_ms,
|
||||||
|
connect_timeout_ms,
|
||||||
|
stream_open_timeout_ms,
|
||||||
),
|
),
|
||||||
crate::cli::Commands::Generate {
|
crate::cli::Commands::Generate {
|
||||||
out,
|
out,
|
||||||
@@ -112,7 +141,24 @@ fn run_listen(
|
|||||||
auth_token: String,
|
auth_token: String,
|
||||||
auth_token_file: Option<String>,
|
auth_token_file: Option<String>,
|
||||||
insecure_skip_tls_verify: bool,
|
insecure_skip_tls_verify: bool,
|
||||||
|
max_open_files: u64,
|
||||||
|
max_tunnel_sessions: usize,
|
||||||
|
max_socks_connections: usize,
|
||||||
|
max_streams_per_tunnel: usize,
|
||||||
|
handshake_timeout_ms: u64,
|
||||||
|
connect_timeout_ms: u64,
|
||||||
|
stream_open_timeout_ms: u64,
|
||||||
) -> i32 {
|
) -> i32 {
|
||||||
|
configure_performance(
|
||||||
|
max_open_files,
|
||||||
|
max_tunnel_sessions,
|
||||||
|
max_socks_connections,
|
||||||
|
max_streams_per_tunnel,
|
||||||
|
handshake_timeout_ms,
|
||||||
|
connect_timeout_ms,
|
||||||
|
stream_open_timeout_ms,
|
||||||
|
);
|
||||||
|
|
||||||
let (host, port) = match cli::parse_host_port(&listen) {
|
let (host, port) = match cli::parse_host_port(&listen) {
|
||||||
Ok(v) => v,
|
Ok(v) => v,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
@@ -310,7 +356,23 @@ fn run_connect(
|
|||||||
auth_token: String,
|
auth_token: String,
|
||||||
auth_token_file: Option<String>,
|
auth_token_file: Option<String>,
|
||||||
insecure_skip_tls_verify: bool,
|
insecure_skip_tls_verify: bool,
|
||||||
|
max_open_files: u64,
|
||||||
|
max_socks_connections: usize,
|
||||||
|
max_streams_per_tunnel: usize,
|
||||||
|
handshake_timeout_ms: u64,
|
||||||
|
connect_timeout_ms: u64,
|
||||||
|
stream_open_timeout_ms: u64,
|
||||||
) -> i32 {
|
) -> i32 {
|
||||||
|
configure_performance(
|
||||||
|
max_open_files,
|
||||||
|
1,
|
||||||
|
max_socks_connections,
|
||||||
|
max_streams_per_tunnel,
|
||||||
|
handshake_timeout_ms,
|
||||||
|
connect_timeout_ms,
|
||||||
|
stream_open_timeout_ms,
|
||||||
|
);
|
||||||
|
|
||||||
let raw_connection_key = connection_key_arg.or(connection_key);
|
let raw_connection_key = connection_key_arg.or(connection_key);
|
||||||
let decoded_key = if let Some(raw) = raw_connection_key {
|
let decoded_key = if let Some(raw) = raw_connection_key {
|
||||||
match ConnectionKey::decode(&raw) {
|
match ConnectionKey::decode(&raw) {
|
||||||
@@ -465,6 +527,26 @@ fn run_connect(
|
|||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn configure_performance(
|
||||||
|
max_open_files: u64,
|
||||||
|
max_tunnel_sessions: usize,
|
||||||
|
max_socks_connections: usize,
|
||||||
|
max_streams_per_tunnel: usize,
|
||||||
|
handshake_timeout_ms: u64,
|
||||||
|
connect_timeout_ms: u64,
|
||||||
|
stream_open_timeout_ms: u64,
|
||||||
|
) {
|
||||||
|
tunnel::set_performance_config(PerformanceConfig {
|
||||||
|
max_open_files,
|
||||||
|
max_tunnel_sessions,
|
||||||
|
max_socks_connections,
|
||||||
|
max_streams_per_tunnel,
|
||||||
|
handshake_timeout: Duration::from_millis(handshake_timeout_ms),
|
||||||
|
connect_timeout: Duration::from_millis(connect_timeout_ms),
|
||||||
|
stream_open_timeout: Duration::from_millis(stream_open_timeout_ms),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
fn select_connect_target<'a>(
|
fn select_connect_target<'a>(
|
||||||
target: Option<&'a str>,
|
target: Option<&'a str>,
|
||||||
decoded_key: Option<&'a ConnectionKey>,
|
decoded_key: Option<&'a ConnectionKey>,
|
||||||
|
|||||||
+544
-121
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user