feat: 文件支持设置代理/策略, 链接支持传入 proxy 参数指定代理/策略; 修复代理/策略优先级

This commit is contained in:
xream
2024-10-07 22:05:07 +08:00
parent 8ffb060cb4
commit ef85b6d0e9
4 changed files with 28 additions and 10 deletions

View File

@@ -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);