From 164c36ed3e85e95e72ea90110444a3388a157da8 Mon Sep 17 00:00:00 2001 From: ospab Date: Mon, 25 May 2026 22:53:06 +0300 Subject: [PATCH] gui: fix compilation errors (update config mappings) --- ostp-gui/src-tauri/src/lib.rs | 41 +++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/ostp-gui/src-tauri/src/lib.rs b/ostp-gui/src-tauri/src/lib.rs index fd3da47..80e0c8b 100644 --- a/ostp-gui/src-tauri/src/lib.rs +++ b/ostp-gui/src-tauri/src/lib.rs @@ -29,7 +29,8 @@ struct ClientConfigRaw { access_key: String, socks5_bind: Option, tun: Option, - turn: Option, + reality: Option, + transport: Option, debug: Option, exclude: Option, mux: Option, @@ -44,11 +45,20 @@ struct TunConfig { } #[derive(Debug, Deserialize, Serialize, Clone)] -struct TurnConfigRaw { - enabled: bool, - server_addr: String, - username: Option, - access_key: Option, +struct RealityConfigRaw { + enabled: Option, + sni: Option, + fp: Option, + pbk: Option, + sid: Option, + spx: Option, +} + +#[derive(Debug, Deserialize, Serialize, Clone)] +struct TransportConfigRaw { + mode: Option, + stealth_sni: Option, + stealth_port: Option, } #[derive(Debug, Deserialize, Serialize, Clone)] @@ -130,7 +140,6 @@ fn get_config_path() -> PathBuf { } fn map_to_client_config(raw: &ClientConfigRaw, mode: &str) -> ostp_client::config::ClientConfig { - let turn_cfg = raw.turn.as_ref(); ostp_client::config::ClientConfig { mode: mode.to_string(), debug: raw.debug.unwrap_or(false), @@ -140,16 +149,24 @@ fn map_to_client_config(raw: &ClientConfigRaw, mode: &str) -> ostp_client::confi access_key: raw.access_key.clone(), handshake_timeout_ms: 5000, io_timeout_ms: 5000, + mtu: 1350, + keepalive_interval_sec: 5, }, local_proxy: ostp_client::config::LocalProxyConfig { bind_addr: raw.socks5_bind.clone().unwrap_or_else(|| "127.0.0.1:1088".to_string()), connect_timeout_ms: 5000, }, - turn: ostp_client::config::TurnConfig { - enabled: turn_cfg.map(|t| t.enabled).unwrap_or(false), - server_addr: turn_cfg.and_then(|t| Some(t.server_addr.clone())).unwrap_or_default(), - username: turn_cfg.and_then(|t| t.username.clone()).unwrap_or_default(), - access_key: turn_cfg.and_then(|t| t.access_key.clone()).unwrap_or_default(), + reality: ostp_client::config::RealityConfig { + sni: raw.reality.as_ref().and_then(|t| t.sni.clone()).unwrap_or_default(), + fp: raw.reality.as_ref().and_then(|t| t.fp.clone()).unwrap_or_default(), + pbk: raw.reality.as_ref().and_then(|t| t.pbk.clone()).unwrap_or_default(), + sid: raw.reality.as_ref().and_then(|t| t.sid.clone()).unwrap_or_default(), + spx: raw.reality.as_ref().and_then(|t| t.spx.clone()).unwrap_or_default(), + }, + transport: ostp_client::config::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: ostp_client::config::ExclusionConfig { domains: raw.exclude.as_ref().and_then(|e| e.domains.clone()).unwrap_or_default(),