mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-10 00:52:40 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2611dccc73 | ||
|
|
25d3cf6ca4 |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sub-store",
|
||||
"version": "2.14.252",
|
||||
"version": "2.14.255",
|
||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
|
||||
"main": "src/main.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -113,7 +113,7 @@ async function downloadSubscription(req, res) {
|
||||
// forward flow headers
|
||||
const flowInfo = await getFlowHeaders(
|
||||
url,
|
||||
undefined,
|
||||
$arguments.flowUserAgent,
|
||||
undefined,
|
||||
sub.proxy,
|
||||
);
|
||||
@@ -250,7 +250,7 @@ async function downloadCollection(req, res) {
|
||||
if (!$arguments.noFlow) {
|
||||
const flowInfo = await getFlowHeaders(
|
||||
url,
|
||||
undefined,
|
||||
$arguments.flowUserAgent,
|
||||
undefined,
|
||||
sub.proxy,
|
||||
);
|
||||
|
||||
@@ -115,7 +115,7 @@ async function getFlowInfo(req, res) {
|
||||
} else {
|
||||
const flowHeaders = await getFlowHeaders(
|
||||
url,
|
||||
undefined,
|
||||
$arguments.flowUserAgent,
|
||||
undefined,
|
||||
sub.proxy,
|
||||
);
|
||||
|
||||
@@ -53,7 +53,7 @@ export default async function download(rawUrl, ua, timeout, proxy) {
|
||||
// return item.content;
|
||||
// }
|
||||
|
||||
const { isNode, isStash } = ENV();
|
||||
const { isNode, isStash, isLoon, isShadowRocket, isQX } = ENV();
|
||||
const { defaultUserAgent, defaultTimeout, cacheThreshold } =
|
||||
$.read(SETTINGS_KEY);
|
||||
const userAgent = ua || defaultUserAgent || 'clash.meta';
|
||||
@@ -66,8 +66,10 @@ export default async function download(rawUrl, ua, timeout, proxy) {
|
||||
const http = HTTP({
|
||||
headers: {
|
||||
'User-Agent': userAgent,
|
||||
'X-Stash-Selected-Proxy':
|
||||
isStash && proxy ? encodeURIComponent(proxy) : undefined,
|
||||
...(isStash && proxy
|
||||
? { 'X-Stash-Selected-Proxy': encodeURIComponent(proxy) }
|
||||
: {}),
|
||||
...(isShadowRocket && proxy ? { 'X-Surge-Policy': proxy } : {}),
|
||||
},
|
||||
timeout: requestTimeout,
|
||||
});
|
||||
@@ -86,8 +88,10 @@ export default async function download(rawUrl, ua, timeout, proxy) {
|
||||
try {
|
||||
const { body, headers } = await http.get({
|
||||
url,
|
||||
proxy,
|
||||
...getPolicyDescriptor(proxy),
|
||||
...(proxy ? { proxy } : {}),
|
||||
...(isLoon && proxy ? { node: proxy } : {}),
|
||||
...(isQX && proxy ? { opts: { policy: proxy } } : {}),
|
||||
...(proxy ? getPolicyDescriptor(proxy) : {}),
|
||||
});
|
||||
|
||||
if (headers) {
|
||||
@@ -125,7 +129,12 @@ export default async function download(rawUrl, ua, timeout, proxy) {
|
||||
if ($arguments?.validCheck) {
|
||||
await validCheck(
|
||||
parseFlowHeaders(
|
||||
await getFlowHeaders(url, undefined, undefined, proxy),
|
||||
await getFlowHeaders(
|
||||
url,
|
||||
$arguments.flowUserAgent,
|
||||
undefined,
|
||||
proxy,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ export async function getFlowHeaders(rawUrl, ua, timeout, proxy) {
|
||||
if ($arguments?.noFlow) {
|
||||
return;
|
||||
}
|
||||
const { isStash } = ENV();
|
||||
const { isStash, isLoon, isShadowRocket, isQX } = ENV();
|
||||
const cached = headersResourceCache.get(url);
|
||||
let flowInfo;
|
||||
if (!$arguments?.noCache && cached) {
|
||||
@@ -49,7 +49,11 @@ export async function getFlowHeaders(rawUrl, ua, timeout, proxy) {
|
||||
const requestTimeout = timeout || defaultTimeout;
|
||||
const http = HTTP();
|
||||
try {
|
||||
// $.info(`使用 HEAD 方法获取流量信息: ${url}`);
|
||||
$.info(
|
||||
`使用 HEAD 方法获取流量信息: ${url}, User-Agent: ${
|
||||
userAgent || ''
|
||||
}`,
|
||||
);
|
||||
const { headers } = await http.head({
|
||||
url: url
|
||||
.split(/[\r\n]+/)
|
||||
@@ -57,23 +61,36 @@ export async function getFlowHeaders(rawUrl, ua, timeout, proxy) {
|
||||
.filter((i) => i.length)[0],
|
||||
headers: {
|
||||
'User-Agent': userAgent,
|
||||
'X-Stash-Selected-Proxy':
|
||||
isStash && proxy
|
||||
? encodeURIComponent(proxy)
|
||||
: undefined,
|
||||
...(isStash && proxy
|
||||
? {
|
||||
'X-Stash-Selected-Proxy':
|
||||
encodeURIComponent(proxy),
|
||||
}
|
||||
: {}),
|
||||
...(isShadowRocket && proxy
|
||||
? { 'X-Surge-Policy': proxy }
|
||||
: {}),
|
||||
},
|
||||
timeout: requestTimeout,
|
||||
proxy,
|
||||
...getPolicyDescriptor(proxy),
|
||||
...(proxy ? { proxy } : {}),
|
||||
...(isLoon && proxy ? { node: proxy } : {}),
|
||||
...(isQX && proxy ? { opts: { policy: proxy } } : {}),
|
||||
...(proxy ? getPolicyDescriptor(proxy) : {}),
|
||||
});
|
||||
flowInfo = getFlowField(headers);
|
||||
} catch (e) {
|
||||
$.error(
|
||||
`使用 HEAD 方法获取流量信息失败: ${url}: ${e.message ?? e}`,
|
||||
`使用 HEAD 方法获取流量信息失败: ${url}, User-Agent: ${
|
||||
userAgent || ''
|
||||
}: ${e.message ?? e}`,
|
||||
);
|
||||
}
|
||||
if (!flowInfo) {
|
||||
$.info(`使用 GET 方法获取流量信息: ${url}`);
|
||||
$.info(
|
||||
`使用 GET 方法获取流量信息: ${url}, User-Agent: ${
|
||||
userAgent || ''
|
||||
}`,
|
||||
);
|
||||
const { headers } = await http.get({
|
||||
url: url
|
||||
.split(/[\r\n]+/)
|
||||
|
||||
1
backend/src/vendor/open-api.js
vendored
1
backend/src/vendor/open-api.js
vendored
@@ -316,6 +316,7 @@ export function HTTP(defaultOptions = { baseURL: '' }) {
|
||||
url: options.url,
|
||||
headers: options.headers,
|
||||
body: options.body,
|
||||
opts: options.opts,
|
||||
});
|
||||
} else if (isLoon || isSurge || isNode) {
|
||||
worker = new Promise((resolve, reject) => {
|
||||
|
||||
Reference in New Issue
Block a user