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 <[email protected]>
This commit is contained in:
1 parent
5596c79490
commit
c6f6ce2cc2
2 files changed
+9
-2
No files matched your search
+1
-1
@@ -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"
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user