mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-11 01:18:59 +08:00
feat: 文件支持设置 查询流量信息订阅链接. 服务器版中使用此链接可在响应中传递订阅流量信息
This commit is contained in:
parent
bfe072cbdf
commit
f524920c13
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.14.344",
|
"version": "2.14.345",
|
||||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
|
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
|
||||||
"main": "src/main.js",
|
"main": "src/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { deleteByName, findByName, updateByName } from '@/utils/database';
|
import { deleteByName, findByName, updateByName } from '@/utils/database';
|
||||||
|
import { getFlowHeaders } from '@/utils/flow';
|
||||||
import { FILES_KEY } from '@/constants';
|
import { FILES_KEY } from '@/constants';
|
||||||
import { failed, success } from '@/restful/response';
|
import { failed, success } from '@/restful/response';
|
||||||
import $ from '@/core/app';
|
import $ from '@/core/app';
|
||||||
@ -50,7 +51,15 @@ async function getFile(req, res) {
|
|||||||
name = decodeURIComponent(name);
|
name = decodeURIComponent(name);
|
||||||
|
|
||||||
$.info(`正在下载文件:${name}`);
|
$.info(`正在下载文件:${name}`);
|
||||||
let { url, ua, content, mergeSources, ignoreFailedRemoteFile } = req.query;
|
let {
|
||||||
|
url,
|
||||||
|
subInfoUrl,
|
||||||
|
subInfoUserAgent,
|
||||||
|
ua,
|
||||||
|
content,
|
||||||
|
mergeSources,
|
||||||
|
ignoreFailedRemoteFile,
|
||||||
|
} = req.query;
|
||||||
if (url) {
|
if (url) {
|
||||||
url = decodeURIComponent(url);
|
url = decodeURIComponent(url);
|
||||||
$.info(`指定远程文件 URL: ${url}`);
|
$.info(`指定远程文件 URL: ${url}`);
|
||||||
@ -59,6 +68,14 @@ async function getFile(req, res) {
|
|||||||
ua = decodeURIComponent(ua);
|
ua = decodeURIComponent(ua);
|
||||||
$.info(`指定远程文件 User-Agent: ${ua}`);
|
$.info(`指定远程文件 User-Agent: ${ua}`);
|
||||||
}
|
}
|
||||||
|
if (subInfoUrl) {
|
||||||
|
subInfoUrl = decodeURIComponent(subInfoUrl);
|
||||||
|
$.info(`指定获取流量的 subInfoUrl: ${subInfoUrl}`);
|
||||||
|
}
|
||||||
|
if (subInfoUserAgent) {
|
||||||
|
subInfoUserAgent = decodeURIComponent(subInfoUserAgent);
|
||||||
|
$.info(`指定获取流量的 subInfoUserAgent: ${subInfoUserAgent}`);
|
||||||
|
}
|
||||||
if (content) {
|
if (content) {
|
||||||
content = decodeURIComponent(content);
|
content = decodeURIComponent(content);
|
||||||
$.info(`指定本地文件: ${content}`);
|
$.info(`指定本地文件: ${content}`);
|
||||||
@ -86,6 +103,26 @@ async function getFile(req, res) {
|
|||||||
ignoreFailedRemoteFile,
|
ignoreFailedRemoteFile,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
subInfoUrl = subInfoUrl || file.subInfoUrl;
|
||||||
|
if (subInfoUrl) {
|
||||||
|
// forward flow headers
|
||||||
|
const flowInfo = await getFlowHeaders(
|
||||||
|
subInfoUrl,
|
||||||
|
subInfoUserAgent || file.subInfoUserAgent,
|
||||||
|
);
|
||||||
|
if (flowInfo) {
|
||||||
|
res.set('subscription-userinfo', flowInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
$.error(
|
||||||
|
`文件 ${name} 获取流量信息时发生错误: ${JSON.stringify(
|
||||||
|
err,
|
||||||
|
)}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
res.set('Content-Type', 'text/plain; charset=utf-8').send(
|
res.set('Content-Type', 'text/plain; charset=utf-8').send(
|
||||||
output ?? '',
|
output ?? '',
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user