Skip to content

Commit

Permalink
feat: 组合订阅支持设置代理/策略, 链接支持传入 proxy 参数指定代理/策略
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Oct 7, 2024
1 parent 6d43961 commit 8ffb060
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
15 changes: 14 additions & 1 deletion backend/src/restful/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ async function downloadSubscription(req, res) {
produceType,
includeUnsupportedProxy,
resultFormat,
proxy,
} = req.query;
let $options = {};
if (req.query.$options) {
Expand All @@ -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}`);
Expand Down Expand Up @@ -135,6 +140,7 @@ async function downloadSubscription(req, res) {
'include-unsupported-proxy': includeUnsupportedProxy,
},
$options,
proxy,
});

if (
Expand Down Expand Up @@ -264,6 +270,7 @@ async function downloadCollection(req, res) {
produceType,
includeUnsupportedProxy,
resultFormat,
proxy,
} = req.query;

let $options = {};
Expand All @@ -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}`);
Expand All @@ -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
Expand Down Expand Up @@ -355,7 +368,7 @@ async function downloadCollection(req, res) {
url,
$arguments.flowUserAgent,
undefined,
sub.proxy,
sub.proxy || collection.proxy || proxy,
$arguments.flowUrl,
);
if (flowInfo) {
Expand Down
10 changes: 6 additions & 4 deletions backend/src/restful/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ async function produceArtifact({
subscription,
awaitCustomCache,
$options,
proxy,
}) {
platform = platform || 'JSON';

Expand Down Expand Up @@ -68,7 +69,7 @@ async function produceArtifact({
url,
ua || sub.ua,
undefined,
sub.proxy,
sub.proxy || proxy,
undefined,
awaitCustomCache,
);
Expand Down Expand Up @@ -115,7 +116,7 @@ async function produceArtifact({
url,
ua || sub.ua,
undefined,
sub.proxy,
sub.proxy || proxy,
undefined,
awaitCustomCache,
);
Expand Down Expand Up @@ -220,7 +221,9 @@ async function produceArtifact({
url,
sub.ua,
undefined,
sub.proxy,
sub.proxy ||
collection.proxy ||
proxy,
);
} catch (err) {
errors[url] = err;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 8ffb060

Please sign in to comment.