feat: 支持使用代理/节点/策略获取订阅

This commit is contained in:
xream
2024-03-13 01:55:16 +08:00
parent ca65e4209e
commit 80d46597b4
8 changed files with 88 additions and 17 deletions

View File

@@ -111,7 +111,12 @@ async function downloadSubscription(req, res) {
}
if (!$arguments.noFlow) {
// forward flow headers
const flowInfo = await getFlowHeaders(url);
const flowInfo = await getFlowHeaders(
url,
undefined,
undefined,
sub.proxy,
);
if (flowInfo) {
res.set('subscription-userinfo', flowInfo);
}
@@ -243,7 +248,12 @@ async function downloadCollection(req, res) {
}
}
if (!$arguments.noFlow) {
const flowInfo = await getFlowHeaders(url);
const flowInfo = await getFlowHeaders(
url,
undefined,
undefined,
sub.proxy,
);
if (flowInfo) {
res.set('subscription-userinfo', flowInfo);
}

View File

@@ -109,7 +109,12 @@ async function compareSub(req, res) {
.filter((i) => i.length)
.map(async (url) => {
try {
return await download(url, sub.ua);
return await download(
url,
sub.ua,
undefined,
sub.proxy,
);
} catch (err) {
errors[url] = err;
$.error(
@@ -195,7 +200,12 @@ async function compareCollection(req, res) {
.filter((i) => i.length)
.map(async (url) => {
try {
return await download(url, sub.ua);
return await download(
url,
sub.ua,
undefined,
sub.proxy,
);
} catch (err) {
errors[url] = err;
$.error(

View File

@@ -113,7 +113,12 @@ async function getFlowInfo(req, res) {
}),
});
} else {
const flowHeaders = await getFlowHeaders(url);
const flowHeaders = await getFlowHeaders(
url,
undefined,
undefined,
sub.proxy,
);
if (!flowHeaders) {
failed(
res,

View File

@@ -62,7 +62,12 @@ async function produceArtifact({
.filter((i) => i.length)
.map(async (url) => {
try {
return await download(url, ua || sub.ua);
return await download(
url,
ua || sub.ua,
undefined,
sub.proxy,
);
} catch (err) {
errors[url] = err;
$.error(
@@ -102,7 +107,12 @@ async function produceArtifact({
.filter((i) => i.length)
.map(async (url) => {
try {
return await download(url, ua || sub.ua);
return await download(
url,
ua || sub.ua,
undefined,
sub.proxy,
);
} catch (err) {
errors[url] = err;
$.error(
@@ -198,7 +208,12 @@ async function produceArtifact({
.filter((i) => i.length)
.map(async (url) => {
try {
return await download(url, sub.ua);
return await download(
url,
sub.ua,
undefined,
sub.proxy,
);
} catch (err) {
errors[url] = err;
$.error(