From ef85b6d0e98da79ea524429203e4f1bdde1b9347 Mon Sep 17 00:00:00 2001 From: xream Date: Mon, 7 Oct 2024 22:05:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=87=E4=BB=B6=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=BB=A3=E7=90=86/=E7=AD=96=E7=95=A5,=20?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E6=94=AF=E6=8C=81=E4=BC=A0=E5=85=A5=20`proxy?= =?UTF-8?q?`=20=E5=8F=82=E6=95=B0=E6=8C=87=E5=AE=9A=E4=BB=A3=E7=90=86/?= =?UTF-8?q?=E7=AD=96=E7=95=A5;=20=E4=BF=AE=E5=A4=8D=E4=BB=A3=E7=90=86/?= =?UTF-8?q?=E7=AD=96=E7=95=A5=E4=BC=98=E5=85=88=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package.json | 2 +- backend/src/restful/download.js | 4 ++-- backend/src/restful/file.js | 8 ++++++++ backend/src/restful/sync.js | 24 +++++++++++++++++------- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/backend/package.json b/backend/package.json index 36c99ac..899d31d 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.14.390", + "version": "2.14.391", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.", "main": "src/main.js", "scripts": { diff --git a/backend/src/restful/download.js b/backend/src/restful/download.js index 41a70fc..bb24f97 100644 --- a/backend/src/restful/download.js +++ b/backend/src/restful/download.js @@ -181,7 +181,7 @@ async function downloadSubscription(req, res) { url, $arguments.flowUserAgent, undefined, - sub.proxy, + proxy || sub.proxy, $arguments.flowUrl, ); if (flowInfo) { @@ -368,7 +368,7 @@ async function downloadCollection(req, res) { url, $arguments.flowUserAgent, undefined, - sub.proxy || collection.proxy || proxy, + proxy || sub.proxy || collection.proxy, $arguments.flowUrl, ); if (flowInfo) { diff --git a/backend/src/restful/file.js b/backend/src/restful/file.js index ff879f1..bef2871 100644 --- a/backend/src/restful/file.js +++ b/backend/src/restful/file.js @@ -59,6 +59,7 @@ async function getFile(req, res) { content, mergeSources, ignoreFailedRemoteFile, + proxy, } = req.query; let $options = {}; if (req.query.$options) { @@ -82,6 +83,10 @@ async function getFile(req, res) { url = decodeURIComponent(url); $.info(`指定远程文件 URL: ${url}`); } + if (proxy) { + proxy = decodeURIComponent(proxy); + $.info(`指定远程订阅使用代理/策略 proxy: ${proxy}`); + } if (ua) { ua = decodeURIComponent(ua); $.info(`指定远程文件 User-Agent: ${ua}`); @@ -120,6 +125,7 @@ async function getFile(req, res) { mergeSources, ignoreFailedRemoteFile, $options, + proxy, }); try { @@ -129,6 +135,8 @@ async function getFile(req, res) { const flowInfo = await getFlowHeaders( subInfoUrl, subInfoUserAgent || file.subInfoUserAgent, + undefined, + proxy || file.proxy, ); if (flowInfo) { res.set('subscription-userinfo', flowInfo); diff --git a/backend/src/restful/sync.js b/backend/src/restful/sync.js index 63e559b..03a9e28 100644 --- a/backend/src/restful/sync.js +++ b/backend/src/restful/sync.js @@ -69,7 +69,7 @@ async function produceArtifact({ url, ua || sub.ua, undefined, - sub.proxy || proxy, + proxy || sub.proxy, undefined, awaitCustomCache, ); @@ -116,7 +116,7 @@ async function produceArtifact({ url, ua || sub.ua, undefined, - sub.proxy || proxy, + proxy || sub.proxy, undefined, awaitCustomCache, ); @@ -221,9 +221,9 @@ async function produceArtifact({ url, sub.ua, undefined, - sub.proxy || - collection.proxy || - proxy, + proxy || + sub.proxy || + collection.proxy, ); } catch (err) { errors[url] = err; @@ -392,7 +392,12 @@ async function produceArtifact({ .filter((i) => i.length) .map(async (url) => { try { - return await download(url, ua || file.ua); + return await download( + url, + ua || file.ua, + undefined, + file.proxy || proxy, + ); } catch (err) { errors[url] = err; $.error( @@ -435,7 +440,12 @@ async function produceArtifact({ .filter((i) => i.length) .map(async (url) => { try { - return await download(url, ua || file.ua); + return await download( + url, + ua || file.ua, + undefined, + file.proxy || proxy, + ); } catch (err) { errors[url] = err; $.error(