From c6f6ce2cc2ad1d873e65ddde89344ff7c5b0c5ad Mon Sep 17 00:00:00 2001 From: cpp1992 Date: Thu, 14 May 2026 04:25:18 +0800 Subject: [PATCH] fix(stealth): pass proxy config to StealthHttpClient (#141) When --stealth is enabled, StealthHttpClient was created without the proxy URL from --proxy, causing all stealth-mode requests to bypass the proxy. Also convert SOCKS5 proxy URL to HTTP when passing to wreq-based StealthHttpClient, because wreq does not support SOCKS5 protocol (Clash mixed port supports both protocols on the same port). Fixes proxy connectivity for 'obscura serve --stealth --proxy socks5://...' Co-authored-by: handsome.cheng --- Cargo.toml | 2 +- crates/obscura-browser/src/page.rs | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ebdb8d3..90e073f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ servo_arc = "0.4" cssparser = "0.34" tokio = { version = "1", features = ["full"] } tokio-tungstenite = "0.26" -reqwest = { version = "0.12", features = ["cookies", "gzip", "brotli", "deflate", "native-tls-vendored"], default-features = false } +reqwest = { version = "0.12", features = ["cookies", "gzip", "brotli", "deflate", "native-tls-vendored", "socks"], default-features = false } serde = { version = "1", features = ["derive"] } serde_json = "1" url = "2" diff --git a/crates/obscura-browser/src/page.rs b/crates/obscura-browser/src/page.rs index 94fb566..a7c5082 100644 --- a/crates/obscura-browser/src/page.rs +++ b/crates/obscura-browser/src/page.rs @@ -54,7 +54,14 @@ impl Page { let frame_id = id.clone(); #[cfg(feature = "stealth")] let stealth_client = if context.stealth { - Some(Arc::new(StealthHttpClient::new(context.cookie_jar.clone()))) + // wreq doesn't support SOCKS5; Clash mixed port handles both. + let stealth_proxy = context.proxy_url.as_ref().map(|u| { + u.replacen("socks5://", "http://", 1) + }); + Some(Arc::new(StealthHttpClient::with_proxy( + context.cookie_jar.clone(), + stealth_proxy.as_deref(), + ))) } else { None };