fix: Do not use proxy when test on tun mode

This commit is contained in:
MystiPanda 2024-01-17 18:08:09 +08:00
parent 2d171db672
commit c9e78c837b

View File

@ -377,23 +377,26 @@ pub async fn test_delay(url: String) -> Result<u32> {
.latest() .latest()
.verge_mixed_port .verge_mixed_port
.unwrap_or(Config::clash().data().get_mixed_port()); .unwrap_or(Config::clash().data().get_mixed_port());
let tun_mode = Config::verge().latest().enable_tun_mode.unwrap_or(false);
let proxy_scheme = format!("http://127.0.0.1:{port}"); let proxy_scheme = format!("http://127.0.0.1:{port}");
if let Ok(proxy) = reqwest::Proxy::http(&proxy_scheme) { if !tun_mode {
builder = builder.proxy(proxy); if let Ok(proxy) = reqwest::Proxy::http(&proxy_scheme) {
} builder = builder.proxy(proxy);
if let Ok(proxy) = reqwest::Proxy::https(&proxy_scheme) { }
builder = builder.proxy(proxy); if let Ok(proxy) = reqwest::Proxy::https(&proxy_scheme) {
} builder = builder.proxy(proxy);
if let Ok(proxy) = reqwest::Proxy::all(&proxy_scheme) { }
builder = builder.proxy(proxy); if let Ok(proxy) = reqwest::Proxy::all(&proxy_scheme) {
builder = builder.proxy(proxy);
}
} }
let request = builder let request = builder
.timeout(Duration::from_millis(10000)) .timeout(Duration::from_millis(10000))
.build()? .build()?
.get(url); .get(url).header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0");
let start = Instant::now(); let start = Instant::now();
let response = request.send().await?; let response = request.send().await?;