From 8ffb060cb4eabb77076c3f1d74e2f2d741ca1836 Mon Sep 17 00:00:00 2001 From: xream Date: Mon, 7 Oct 2024 20:56:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=BB=84=E5=90=88=E8=AE=A2=E9=98=85?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=AE=BE=E7=BD=AE=E4=BB=A3=E7=90=86/?= =?UTF-8?q?=E7=AD=96=E7=95=A5,=20=E9=93=BE=E6=8E=A5=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E4=BC=A0=E5=85=A5=20`proxy`=20=E5=8F=82=E6=95=B0=E6=8C=87?= =?UTF-8?q?=E5=AE=9A=E4=BB=A3=E7=90=86/=E7=AD=96=E7=95=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package.json | 2 +- backend/src/restful/download.js | 15 ++++++++++++++- backend/src/restful/sync.js | 10 ++++++---- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/backend/package.json b/backend/package.json index d282207..36c99ac 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.14.389", + "version": "2.14.390", "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 4af2461..41a70fc 100644 --- a/backend/src/restful/download.js +++ b/backend/src/restful/download.js @@ -69,6 +69,7 @@ async function downloadSubscription(req, res) { produceType, includeUnsupportedProxy, resultFormat, + proxy, } = req.query; let $options = {}; if (req.query.$options) { @@ -92,6 +93,10 @@ async function downloadSubscription(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}`); @@ -135,6 +140,7 @@ async function downloadSubscription(req, res) { 'include-unsupported-proxy': includeUnsupportedProxy, }, $options, + proxy, }); if ( @@ -264,6 +270,7 @@ async function downloadCollection(req, res) { produceType, includeUnsupportedProxy, resultFormat, + proxy, } = req.query; let $options = {}; @@ -285,6 +292,11 @@ async function downloadCollection(req, res) { $.info(`传入 $options: ${JSON.stringify($options)}`); } + if (proxy) { + proxy = decodeURIComponent(proxy); + $.info(`指定远程订阅使用代理/策略 proxy: ${proxy}`); + } + if (ignoreFailedRemoteSub != null && ignoreFailedRemoteSub !== '') { ignoreFailedRemoteSub = decodeURIComponent(ignoreFailedRemoteSub); $.info(`指定忽略失败的远程订阅: ${ignoreFailedRemoteSub}`); @@ -311,6 +323,7 @@ async function downloadCollection(req, res) { 'include-unsupported-proxy': includeUnsupportedProxy, }, $options, + proxy, }); // forward flow header from the first subscription in this collection @@ -355,7 +368,7 @@ async function downloadCollection(req, res) { url, $arguments.flowUserAgent, undefined, - sub.proxy, + sub.proxy || collection.proxy || proxy, $arguments.flowUrl, ); if (flowInfo) { diff --git a/backend/src/restful/sync.js b/backend/src/restful/sync.js index dfa30bc..63e559b 100644 --- a/backend/src/restful/sync.js +++ b/backend/src/restful/sync.js @@ -38,6 +38,7 @@ async function produceArtifact({ subscription, awaitCustomCache, $options, + proxy, }) { platform = platform || 'JSON'; @@ -68,7 +69,7 @@ async function produceArtifact({ url, ua || sub.ua, undefined, - sub.proxy, + sub.proxy || proxy, undefined, awaitCustomCache, ); @@ -115,7 +116,7 @@ async function produceArtifact({ url, ua || sub.ua, undefined, - sub.proxy, + sub.proxy || proxy, undefined, awaitCustomCache, ); @@ -220,7 +221,9 @@ async function produceArtifact({ url, sub.ua, undefined, - sub.proxy, + sub.proxy || + collection.proxy || + proxy, ); } catch (err) { errors[url] = err; @@ -344,7 +347,6 @@ async function produceArtifact({ } exist[proxy.name] = true; } - console.log(proxies); return ProxyUtils.produce(proxies, platform, produceType, produceOpts); } else if (type === 'rule') { const allRules = $.read(RULES_KEY);