From ddd46628987812c81f53da3c23518200ab8dea51 Mon Sep 17 00:00:00 2001 From: NimBold Date: Tue, 23 Jun 2026 04:21:25 +0330 Subject: [PATCH] fix(network): explicitly disable proxy fallbacks for none and system modes Disabled implicit system/environment variable proxy fallbacks in reqwest, yt-dlp, and aria2c when no proxy is explicitly provided. Updated useDownloadStore to strictly return 'none' when 'none' is selected or when 'system' proxy is empty, matching IDM/FDM behavior and ignoring http_proxy environment variables. --- src-tauri/src/download.rs | 6 +++++- src-tauri/src/lib.rs | 6 ++++-- src-tauri/src/queue.rs | 8 ++++++-- src/store/useDownloadStore.ts | 8 ++++++-- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src-tauri/src/download.rs b/src-tauri/src/download.rs index 7ca2cfa..e6bd821 100644 --- a/src-tauri/src/download.rs +++ b/src-tauri/src/download.rs @@ -703,7 +703,11 @@ fn build_client(payload: &DownloadPayload) -> Result { builder = builder.user_agent(user_agent); } if let Some(proxy) = payload.proxy.as_deref().filter(|value| !value.is_empty()) { - builder = builder.proxy(reqwest::Proxy::all(proxy).map_err(|error| error.to_string())?); + if proxy == "none" { + builder = builder.no_proxy(); + } else { + builder = builder.proxy(reqwest::Proxy::all(proxy).map_err(|error| error.to_string())?); + } } builder.build().map_err(|error| error.to_string()) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index df8726d..bccc0d7 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -2085,8 +2085,10 @@ pub(crate) async fn start_media_download_internal( } } - if let Some(p) = proxy.as_ref() { - if !p.is_empty() { + if let Some(p) = proxy.as_ref().filter(|s| !s.is_empty()) { + if p == "none" { + cmd = cmd.arg("--proxy").arg(""); + } else { cmd = cmd.arg("--proxy").arg(p); } } diff --git a/src-tauri/src/queue.rs b/src-tauri/src/queue.rs index 293574b..42ef407 100644 --- a/src-tauri/src/queue.rs +++ b/src-tauri/src/queue.rs @@ -872,8 +872,12 @@ impl SidecarSpawner for ProductionSpawner { if !header_list.is_empty() { options.insert("header".to_string(), serde_json::json!(header_list)); } - if let Some(prox) = &payload.proxy { - options.insert("all-proxy".to_string(), serde_json::json!(prox)); + if let Some(prox) = payload.proxy.as_deref().filter(|s| !s.is_empty()) { + if prox == "none" { + options.insert("all-proxy".to_string(), serde_json::json!("")); + } else { + options.insert("all-proxy".to_string(), serde_json::json!(prox)); + } } let uris = crate::collect_download_uris(&payload.url, payload.mirrors.as_deref()); let params = serde_json::json!([uris, options]); diff --git a/src/store/useDownloadStore.ts b/src/store/useDownloadStore.ts index 4bd4a96..30c6cb5 100644 --- a/src/store/useDownloadStore.ts +++ b/src/store/useDownloadStore.ts @@ -88,15 +88,19 @@ export async function dispatchItem(id: string): Promise { const getProxyArgs = async (settings: ReturnType) => { if (settings.proxyMode === 'system') { try { - return await invoke('get_system_proxy'); + const sysProxy = await invoke('get_system_proxy'); + return typeof sysProxy === 'string' && sysProxy ? sysProxy : "none"; } catch (e) { console.warn("Failed to get system proxy:", e); - return null; + return "none"; } } if (settings.proxyMode === 'custom' && settings.proxyHost) { return `http://${settings.proxyHost}:${settings.proxyPort}`; } + if (settings.proxyMode === 'none') { + return "none"; + } return null; };