fix(proxy): harden system proxy metadata flow

Normalize system proxy values from sysproxy, Windows registry, and environment fallbacks before handing them to download engines.

Apply the resolved proxy to direct metadata probes and yt-dlp media metadata requests so preview and final downloads use the same network path.

Enable reqwest SOCKS support and key media metadata caches by proxy/cookie inputs to avoid stale cross-proxy reuse.
This commit is contained in:
NimBold
2026-07-06 00:41:34 +03:30
parent 017d9cd879
commit c13f993150
6 changed files with 269 additions and 59 deletions
+7 -4
View File
@@ -2,6 +2,7 @@ import { useState, useEffect, useRef } from 'react';
import {
useDownloadStore,
getSiteLogin,
getProxyArgs,
type AddDownloadAction
} from '../store/useDownloadStore';
import { useSettingsStore } from '../store/useSettingsStore';
@@ -186,8 +187,9 @@ export const AddDownloadsModal = () => {
void (async () => {
try {
const settingsStore = useSettingsStore.getState();
const proxy = await getProxyArgs(settingsStore);
if (row.isMedia) {
const settingsStore = useSettingsStore.getState();
const { mediaCookieSource } = settingsStore;
const browserArg = mediaCookieSource !== 'none' ? mediaCookieSource : null;
const login = getSiteLogin(row.sourceUrl, settingsStore);
@@ -204,7 +206,8 @@ export const AddDownloadsModal = () => {
url: row.sourceUrl,
cookieBrowser: browserArg,
username: useAuth ? username.trim() || null : login?.username || null,
password: useAuth ? password || null : keychainPassword
password: useAuth ? password || null : keychainPassword,
proxy
});
if (mediaData && mediaData.formats.length > 0) {
const mappedFormats = mediaData.formats.map(f => {
@@ -245,7 +248,6 @@ export const AddDownloadsModal = () => {
throw new Error("Invalid media metadata or no formats found");
}
} else {
const settingsStore = useSettingsStore.getState();
const login = getSiteLogin(row.sourceUrl, settingsStore);
let keychainPassword = null;
if (login) {
@@ -261,7 +263,8 @@ export const AddDownloadsModal = () => {
username: useAuth ? username.trim() || null : login?.username || null,
password: useAuth ? password || null : keychainPassword,
headers: headers?.trim() || null,
cookies: cookies?.trim() || null
cookies: cookies?.trim() || null,
proxy
});
const nextDownloadUrl = meta.url || row.sourceUrl;
if (cookiesFromExtensionRef.current && isCrossHostRedirect(row.sourceUrl, nextDownloadUrl)) {
+2 -2
View File
@@ -17,11 +17,11 @@ import type { PlatformInfo } from './bindings/PlatformInfo';
type CommandMap = {
fetch_metadata: {
args: { url: string; userAgent: string | null; username: string | null; password: string | null; headers: string | null; cookies: string | null };
args: { url: string; userAgent: string | null; username: string | null; password: string | null; headers: string | null; cookies: string | null; proxy: string | null };
result: MetadataResponse;
};
fetch_media_metadata: {
args: { url: string; cookieBrowser: string | null; username: string | null; password: string | null };
args: { url: string; cookieBrowser: string | null; username: string | null; password: string | null; proxy: string | null };
result: MediaMetadata;
};
get_aria2_engine_status: { args: undefined; result: EngineStatusItem };
+2 -1
View File
@@ -6,12 +6,13 @@ type FetchMediaMetadataArgs = {
cookieBrowser: string | null;
username: string | null;
password: string | null;
proxy: string | null;
};
const inFlightMediaMetadata = new Map<string, Promise<MediaMetadata>>();
const metadataKey = (args: FetchMediaMetadataArgs) =>
JSON.stringify([args.url, args.cookieBrowser, args.username, args.password]);
JSON.stringify([args.url, args.cookieBrowser, args.username, args.password, args.proxy]);
export const fetchMediaMetadataDeduped = (args: FetchMediaMetadataArgs): Promise<MediaMetadata> => {
const key = metadataKey(args);