diff --git a/ostp-client/src/config.rs b/ostp-client/src/config.rs index 8fabe49..f4e558a 100644 --- a/ostp-client/src/config.rs +++ b/ostp-client/src/config.rs @@ -159,6 +159,14 @@ struct RawUnifiedConfig { exclude: Option, mux: Option, turn: Option, + transport: Option, +} + +#[derive(Debug, Deserialize)] +struct RawTransportSection { + mode: Option, + stealth_sni: Option, + stealth_port: Option, } #[derive(Debug, Deserialize)] @@ -232,14 +240,16 @@ impl ClientConfig { bind_addr: socks5, connect_timeout_ms: 15000, }, - turn: match raw.turn { - Some(t) => TurnConfig { - enabled: t.enabled.unwrap_or(false), - server_addr: t.server_addr.unwrap_or_default(), - username: t.username.unwrap_or_default(), - access_key: t.access_key.unwrap_or_default(), - }, - None => TurnConfig::default(), + turn: TurnConfig { + enabled: raw.turn.as_ref().and_then(|t| t.enabled).unwrap_or(false), + server_addr: raw.turn.as_ref().and_then(|t| t.server_addr.clone()).unwrap_or_default(), + username: raw.turn.as_ref().and_then(|t| t.username.clone()).unwrap_or_default(), + access_key: raw.turn.as_ref().and_then(|t| t.access_key.clone()).unwrap_or_default(), + }, + transport: TransportConfig { + mode: raw.transport.as_ref().and_then(|t| t.mode.clone()).unwrap_or_else(|| "udp".to_string()), + stealth_sni: raw.transport.as_ref().and_then(|t| t.stealth_sni.clone()).unwrap_or_else(|| "microsoft.com".to_string()), + stealth_port: raw.transport.as_ref().and_then(|t| t.stealth_port).unwrap_or(443), }, exclusions: ExclusionConfig { domains: exclusions.domains.unwrap_or_default(), @@ -250,7 +260,6 @@ impl ClientConfig { enabled: mux.enabled.unwrap_or(false), sessions: mux.sessions.unwrap_or(1), }, - transport: TransportConfig::default(), dns_server: raw.tun.as_ref().and_then(|t| t.dns.clone()), }) diff --git a/ostp/src/main.rs b/ostp/src/main.rs index 2a849ad..1d6f1ae 100644 --- a/ostp/src/main.rs +++ b/ostp/src/main.rs @@ -60,6 +60,7 @@ fn parse_ostp_link(link: &str) -> Result { server, access_key, mtu: None, + transport: None, socks5_bind: Some("127.0.0.1:1088".to_string()), // Fallback to standard SOCKS5 port tun: Some(TunConfig { enable: false, // Default to proxy, configurable via settings GUI @@ -196,6 +197,14 @@ struct ClientConfig { debug: Option, exclude: Option, mux: Option, + transport: Option, +} + +#[derive(Debug, Deserialize, Serialize, Clone)] +struct TransportConfigRaw { + mode: Option, + stealth_sni: Option, + stealth_port: Option, } #[derive(Debug, Deserialize, Serialize, Clone)] @@ -657,7 +666,11 @@ async fn run_client_directly(client_cfg: ClientConfig) -> Result<()> { enabled: client_cfg.mux.as_ref().and_then(|m| m.enabled).unwrap_or(false), sessions: client_cfg.mux.as_ref().and_then(|m| m.sessions).unwrap_or(1), }, - transport: ostp_client::config::TransportConfig::default(), + transport: ostp_client::config::TransportConfig { + mode: client_cfg.transport.as_ref().and_then(|t| t.mode.clone()).unwrap_or_else(|| "udp".to_string()), + stealth_sni: client_cfg.transport.as_ref().and_then(|t| t.stealth_sni.clone()).unwrap_or_else(|| "microsoft.com".to_string()), + stealth_port: client_cfg.transport.as_ref().and_then(|t| t.stealth_port).unwrap_or(443), + }, dns_server: client_cfg.tun.as_ref().and_then(|t| t.dns.clone()), };