mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-12 01:29:00 +08:00
feat: 通过代理/节点/策略获取订阅 现已支持 Surge, Loon, Stash, Shadowrocket, QX, Node.js
This commit is contained in:
parent
3637c5eb74
commit
25d3cf6ca4
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.14.252",
|
"version": "2.14.254",
|
||||||
"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": {
|
||||||
|
@ -53,7 +53,7 @@ export default async function download(rawUrl, ua, timeout, proxy) {
|
|||||||
// return item.content;
|
// return item.content;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
const { isNode, isStash } = ENV();
|
const { isNode, isStash, isLoon, isShadowRocket, isQX } = ENV();
|
||||||
const { defaultUserAgent, defaultTimeout, cacheThreshold } =
|
const { defaultUserAgent, defaultTimeout, cacheThreshold } =
|
||||||
$.read(SETTINGS_KEY);
|
$.read(SETTINGS_KEY);
|
||||||
const userAgent = ua || defaultUserAgent || 'clash.meta';
|
const userAgent = ua || defaultUserAgent || 'clash.meta';
|
||||||
@ -66,8 +66,10 @@ export default async function download(rawUrl, ua, timeout, proxy) {
|
|||||||
const http = HTTP({
|
const http = HTTP({
|
||||||
headers: {
|
headers: {
|
||||||
'User-Agent': userAgent,
|
'User-Agent': userAgent,
|
||||||
'X-Stash-Selected-Proxy':
|
...(isStash && proxy
|
||||||
isStash && proxy ? encodeURIComponent(proxy) : undefined,
|
? { 'X-Stash-Selected-Proxy': encodeURIComponent(proxy) }
|
||||||
|
: {}),
|
||||||
|
...(isShadowRocket && proxy ? { 'X-Surge-Policy': proxy } : {}),
|
||||||
},
|
},
|
||||||
timeout: requestTimeout,
|
timeout: requestTimeout,
|
||||||
});
|
});
|
||||||
@ -86,8 +88,10 @@ export default async function download(rawUrl, ua, timeout, proxy) {
|
|||||||
try {
|
try {
|
||||||
const { body, headers } = await http.get({
|
const { body, headers } = await http.get({
|
||||||
url,
|
url,
|
||||||
proxy,
|
...(proxy ? { proxy } : {}),
|
||||||
...getPolicyDescriptor(proxy),
|
...(isLoon && proxy ? { node: proxy } : {}),
|
||||||
|
...(isQX && proxy ? { opts: { policy: proxy } } : {}),
|
||||||
|
...(proxy ? getPolicyDescriptor(proxy) : {}),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (headers) {
|
if (headers) {
|
||||||
|
@ -34,7 +34,7 @@ export async function getFlowHeaders(rawUrl, ua, timeout, proxy) {
|
|||||||
if ($arguments?.noFlow) {
|
if ($arguments?.noFlow) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { isStash } = ENV();
|
const { isStash, isLoon, isShadowRocket, isQX } = ENV();
|
||||||
const cached = headersResourceCache.get(url);
|
const cached = headersResourceCache.get(url);
|
||||||
let flowInfo;
|
let flowInfo;
|
||||||
if (!$arguments?.noCache && cached) {
|
if (!$arguments?.noCache && cached) {
|
||||||
@ -57,14 +57,21 @@ export async function getFlowHeaders(rawUrl, ua, timeout, proxy) {
|
|||||||
.filter((i) => i.length)[0],
|
.filter((i) => i.length)[0],
|
||||||
headers: {
|
headers: {
|
||||||
'User-Agent': userAgent,
|
'User-Agent': userAgent,
|
||||||
|
...(isStash && proxy
|
||||||
|
? {
|
||||||
'X-Stash-Selected-Proxy':
|
'X-Stash-Selected-Proxy':
|
||||||
isStash && proxy
|
encodeURIComponent(proxy),
|
||||||
? encodeURIComponent(proxy)
|
}
|
||||||
: undefined,
|
: {}),
|
||||||
|
...(isShadowRocket && proxy
|
||||||
|
? { 'X-Surge-Policy': proxy }
|
||||||
|
: {}),
|
||||||
},
|
},
|
||||||
timeout: requestTimeout,
|
timeout: requestTimeout,
|
||||||
proxy,
|
...(proxy ? { proxy } : {}),
|
||||||
...getPolicyDescriptor(proxy),
|
...(isLoon && proxy ? { node: proxy } : {}),
|
||||||
|
...(isQX && proxy ? { opts: { policy: proxy } } : {}),
|
||||||
|
...(proxy ? getPolicyDescriptor(proxy) : {}),
|
||||||
});
|
});
|
||||||
flowInfo = getFlowField(headers);
|
flowInfo = getFlowField(headers);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
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,
|
url: options.url,
|
||||||
headers: options.headers,
|
headers: options.headers,
|
||||||
body: options.body,
|
body: options.body,
|
||||||
|
opts: options.opts,
|
||||||
});
|
});
|
||||||
} else if (isLoon || isSurge || isNode) {
|
} else if (isLoon || isSurge || isNode) {
|
||||||
worker = new Promise((resolve, reject) => {
|
worker = new Promise((resolve, reject) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user