mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-12 20:29:00 +08:00
feat: 支持 flowUrl
This commit is contained in:
parent
533103e765
commit
99d058bcf1
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.14.329",
|
"version": "2.14.330",
|
||||||
"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": {
|
||||||
|
@ -156,6 +156,7 @@ async function downloadSubscription(req, res) {
|
|||||||
$arguments.flowUserAgent,
|
$arguments.flowUserAgent,
|
||||||
undefined,
|
undefined,
|
||||||
sub.proxy,
|
sub.proxy,
|
||||||
|
$arguments.flowUrl,
|
||||||
);
|
);
|
||||||
if (flowInfo) {
|
if (flowInfo) {
|
||||||
res.set('subscription-userinfo', flowInfo);
|
res.set('subscription-userinfo', flowInfo);
|
||||||
@ -314,6 +315,7 @@ async function downloadCollection(req, res) {
|
|||||||
$arguments.flowUserAgent,
|
$arguments.flowUserAgent,
|
||||||
undefined,
|
undefined,
|
||||||
sub.proxy,
|
sub.proxy,
|
||||||
|
$arguments.flowUrl,
|
||||||
);
|
);
|
||||||
if (flowInfo) {
|
if (flowInfo) {
|
||||||
res.set('subscription-userinfo', flowInfo);
|
res.set('subscription-userinfo', flowInfo);
|
||||||
|
@ -118,6 +118,7 @@ async function getFlowInfo(req, res) {
|
|||||||
$arguments.flowUserAgent,
|
$arguments.flowUserAgent,
|
||||||
undefined,
|
undefined,
|
||||||
sub.proxy,
|
sub.proxy,
|
||||||
|
$arguments.flowUrl,
|
||||||
);
|
);
|
||||||
if (!flowHeaders) {
|
if (!flowHeaders) {
|
||||||
failed(
|
failed(
|
||||||
|
@ -217,6 +217,7 @@ export default async function download(
|
|||||||
$arguments.flowUserAgent,
|
$arguments.flowUserAgent,
|
||||||
undefined,
|
undefined,
|
||||||
proxy,
|
proxy,
|
||||||
|
$arguments.flowUrl,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -10,8 +10,8 @@ export function getFlowField(headers) {
|
|||||||
)[0];
|
)[0];
|
||||||
return headers[subkey];
|
return headers[subkey];
|
||||||
}
|
}
|
||||||
export async function getFlowHeaders(rawUrl, ua, timeout, proxy) {
|
export async function getFlowHeaders(rawUrl, ua, timeout, proxy, flowUrl) {
|
||||||
let url = rawUrl;
|
let url = flowUrl || rawUrl;
|
||||||
let $arguments = {};
|
let $arguments = {};
|
||||||
const rawArgs = url.split('#');
|
const rawArgs = url.split('#');
|
||||||
url = url.split('#')[0];
|
url = url.split('#')[0];
|
||||||
@ -48,9 +48,24 @@ export async function getFlowHeaders(rawUrl, ua, timeout, proxy) {
|
|||||||
'Quantumult%20X/1.0.30 (iPhone14,2; iOS 15.6)';
|
'Quantumult%20X/1.0.30 (iPhone14,2; iOS 15.6)';
|
||||||
const requestTimeout = timeout || defaultTimeout;
|
const requestTimeout = timeout || defaultTimeout;
|
||||||
const http = HTTP();
|
const http = HTTP();
|
||||||
|
if (flowUrl) {
|
||||||
|
$.info(
|
||||||
|
`使用 GET 方法从响应体获取流量信息: ${flowUrl}, User-Agent: ${
|
||||||
|
userAgent || ''
|
||||||
|
}`,
|
||||||
|
);
|
||||||
|
const { body } = await http.get({
|
||||||
|
url: flowUrl,
|
||||||
|
headers: {
|
||||||
|
'User-Agent': userAgent,
|
||||||
|
},
|
||||||
|
timeout: requestTimeout,
|
||||||
|
});
|
||||||
|
flowInfo = body;
|
||||||
|
} else {
|
||||||
try {
|
try {
|
||||||
$.info(
|
$.info(
|
||||||
`使用 HEAD 方法获取流量信息: ${url}, User-Agent: ${
|
`使用 HEAD 方法从响应头获取流量信息: ${url}, User-Agent: ${
|
||||||
userAgent || ''
|
userAgent || ''
|
||||||
}`,
|
}`,
|
||||||
);
|
);
|
||||||
@ -80,7 +95,7 @@ export async function getFlowHeaders(rawUrl, ua, timeout, proxy) {
|
|||||||
flowInfo = getFlowField(headers);
|
flowInfo = getFlowField(headers);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
$.error(
|
$.error(
|
||||||
`使用 HEAD 方法获取流量信息失败: ${url}, User-Agent: ${
|
`使用 HEAD 方法从响应头获取流量信息失败: ${url}, User-Agent: ${
|
||||||
userAgent || ''
|
userAgent || ''
|
||||||
}: ${e.message ?? e}`,
|
}: ${e.message ?? e}`,
|
||||||
);
|
);
|
||||||
@ -103,6 +118,7 @@ export async function getFlowHeaders(rawUrl, ua, timeout, proxy) {
|
|||||||
});
|
});
|
||||||
flowInfo = getFlowField(headers);
|
flowInfo = getFlowField(headers);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (flowInfo) {
|
if (flowInfo) {
|
||||||
headersResourceCache.set(url, flowInfo);
|
headersResourceCache.set(url, flowInfo);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user