mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-10 00:52:40 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
005051c4ac | ||
|
|
61078b10f3 | ||
|
|
bfa1b11a0e | ||
|
|
7d60aed50d | ||
|
|
e20d0c1dc9 | ||
|
|
c5660024fb |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.19.74",
|
"version": "2.19.81",
|
||||||
"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": {
|
||||||
@@ -32,6 +32,7 @@
|
|||||||
"dns-packet": "^5.6.1",
|
"dns-packet": "^5.6.1",
|
||||||
"dotenv": "^16.4.7",
|
"dotenv": "^16.4.7",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
|
"fetch-socks": "^1.3.2",
|
||||||
"http-proxy-middleware": "^3.0.3",
|
"http-proxy-middleware": "^3.0.3",
|
||||||
"ip-address": "^9.0.5",
|
"ip-address": "^9.0.5",
|
||||||
"js-base64": "^3.7.2",
|
"js-base64": "^3.7.2",
|
||||||
|
|||||||
26
backend/pnpm-lock.yaml
generated
26
backend/pnpm-lock.yaml
generated
@@ -40,6 +40,9 @@ importers:
|
|||||||
express:
|
express:
|
||||||
specifier: ^4.17.1
|
specifier: ^4.17.1
|
||||||
version: 4.21.2
|
version: 4.21.2
|
||||||
|
fetch-socks:
|
||||||
|
specifier: ^1.3.2
|
||||||
|
version: 1.3.2
|
||||||
http-proxy-middleware:
|
http-proxy-middleware:
|
||||||
specifier: ^3.0.3
|
specifier: ^3.0.3
|
||||||
version: 3.0.3
|
version: 3.0.3
|
||||||
@@ -1974,6 +1977,9 @@ packages:
|
|||||||
fastq@1.18.0:
|
fastq@1.18.0:
|
||||||
resolution: {integrity: sha512-QKHXPW0hD8g4UET03SdOdunzSouc9N4AuHdsX8XNcTsuz+yYFILVNIX4l9yHABMhiEI9Db0JTTIpu0wB+Y1QQw==}
|
resolution: {integrity: sha512-QKHXPW0hD8g4UET03SdOdunzSouc9N4AuHdsX8XNcTsuz+yYFILVNIX4l9yHABMhiEI9Db0JTTIpu0wB+Y1QQw==}
|
||||||
|
|
||||||
|
fetch-socks@1.3.2:
|
||||||
|
resolution: {integrity: sha512-vkH5+Zgj2yEbU57Cei0iyLgTZ4OkEKJj56Xu3ViB5dpsl599JgEooQ3x6NVagIFRHWnWJ+7K0MO0aIV1TMgvnw==}
|
||||||
|
|
||||||
file-entry-cache@6.0.1:
|
file-entry-cache@6.0.1:
|
||||||
resolution: {integrity: sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==}
|
resolution: {integrity: sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==}
|
||||||
engines: {node: ^10.12.0 || >=12.0.0}
|
engines: {node: ^10.12.0 || >=12.0.0}
|
||||||
@@ -3636,6 +3642,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-3TYDR7xWt4dIqV2JauJr+EJeW356RXijHeUlO+8djJ+uBXPn8/2dpzBc8yQhh583sVvc9CvFAeQVgijsH+PNNg==}
|
resolution: {integrity: sha512-3TYDR7xWt4dIqV2JauJr+EJeW356RXijHeUlO+8djJ+uBXPn8/2dpzBc8yQhh583sVvc9CvFAeQVgijsH+PNNg==}
|
||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
|
|
||||||
|
smart-buffer@4.2.0:
|
||||||
|
resolution: {integrity: sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==}
|
||||||
|
engines: {node: '>= 6.0.0', npm: '>= 3.0.0'}
|
||||||
|
|
||||||
snapdragon-node@2.1.1:
|
snapdragon-node@2.1.1:
|
||||||
resolution: {integrity: sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==}
|
resolution: {integrity: sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==}
|
||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
@@ -3648,6 +3658,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==}
|
resolution: {integrity: sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==}
|
||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
|
|
||||||
|
socks@2.8.6:
|
||||||
|
resolution: {integrity: sha512-pe4Y2yzru68lXCb38aAqRf5gvN8YdjP1lok5o0J7BOHljkyCGKVz7H3vpVIXKD27rj2giOJ7DwVyk/GWrPHDWA==}
|
||||||
|
engines: {node: '>= 10.0.0', npm: '>= 3.0.0'}
|
||||||
|
|
||||||
source-map-generator@0.8.0:
|
source-map-generator@0.8.0:
|
||||||
resolution: {integrity: sha512-psgxdGMwl5MZM9S3FWee4EgsEaIjahYV5AzGnwUvPhWeITz/j6rKpysQHlQ4USdxvINlb8lKfWGIXwfkrgtqkA==}
|
resolution: {integrity: sha512-psgxdGMwl5MZM9S3FWee4EgsEaIjahYV5AzGnwUvPhWeITz/j6rKpysQHlQ4USdxvINlb8lKfWGIXwfkrgtqkA==}
|
||||||
engines: {node: '>= 10'}
|
engines: {node: '>= 10'}
|
||||||
@@ -6553,6 +6567,11 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
reusify: 1.0.4
|
reusify: 1.0.4
|
||||||
|
|
||||||
|
fetch-socks@1.3.2:
|
||||||
|
dependencies:
|
||||||
|
socks: 2.8.6
|
||||||
|
undici: 7.4.0
|
||||||
|
|
||||||
file-entry-cache@6.0.1:
|
file-entry-cache@6.0.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
flat-cache: 3.2.0
|
flat-cache: 3.2.0
|
||||||
@@ -8424,6 +8443,8 @@ snapshots:
|
|||||||
|
|
||||||
slash@1.0.0: {}
|
slash@1.0.0: {}
|
||||||
|
|
||||||
|
smart-buffer@4.2.0: {}
|
||||||
|
|
||||||
snapdragon-node@2.1.1:
|
snapdragon-node@2.1.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
define-property: 1.0.0
|
define-property: 1.0.0
|
||||||
@@ -8447,6 +8468,11 @@ snapshots:
|
|||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
|
socks@2.8.6:
|
||||||
|
dependencies:
|
||||||
|
ip-address: 9.0.5
|
||||||
|
smart-buffer: 4.2.0
|
||||||
|
|
||||||
source-map-generator@0.8.0: {}
|
source-map-generator@0.8.0: {}
|
||||||
|
|
||||||
source-map-resolve@0.5.3:
|
source-map-resolve@0.5.3:
|
||||||
|
|||||||
@@ -105,11 +105,11 @@ wireguard = tag equals "wireguard" (section_name/no_error_alert/ip_version/under
|
|||||||
proxy.type = "wireguard-surge";
|
proxy.type = "wireguard-surge";
|
||||||
handleShadowTLS();
|
handleShadowTLS();
|
||||||
}
|
}
|
||||||
hysteria2 = tag equals "hysteria2" address (no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/sni/fast_open/tfo/tls_verification/passwordk/tls_fingerprint/download_bandwidth/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/others)* {
|
hysteria2 = tag equals "hysteria2" address (no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/sni/tls_verification/passwordk/tls_fingerprint/download_bandwidth/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/others)* {
|
||||||
proxy.type = "hysteria2";
|
proxy.type = "hysteria2";
|
||||||
handleShadowTLS();
|
handleShadowTLS();
|
||||||
}
|
}
|
||||||
socks5 = tag equals "socks5" address (username password)? (usernamek passwordk)? (udp_relay/no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
socks5 = tag equals "socks5" address (username password)? (usernamek passwordk)? (udp_relay/no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
||||||
proxy.type = "socks5";
|
proxy.type = "socks5";
|
||||||
handleShadowTLS();
|
handleShadowTLS();
|
||||||
}
|
}
|
||||||
@@ -121,7 +121,6 @@ socks5_tls = tag equals "socks5-tls" address (username password)? (usernamek pas
|
|||||||
direct = tag equals "direct" (udp_relay/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/block_quic/others)* {
|
direct = tag equals "direct" (udp_relay/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/block_quic/others)* {
|
||||||
proxy.type = "direct";
|
proxy.type = "direct";
|
||||||
}
|
}
|
||||||
|
|
||||||
address = comma server:server comma port:port {
|
address = comma server:server comma port:port {
|
||||||
proxy.server = server;
|
proxy.server = server;
|
||||||
proxy.port = port;
|
proxy.port = port;
|
||||||
@@ -212,11 +211,11 @@ ws_headers = comma "ws-headers" equals headers:$[^,]+ {
|
|||||||
const result = {};
|
const result = {};
|
||||||
pairs.forEach(pair => {
|
pairs.forEach(pair => {
|
||||||
const [key, value] = pair.trim().split(":");
|
const [key, value] = pair.trim().split(":");
|
||||||
result[key.trim()] = value.trim();
|
result[key.trim()] = value.trim().replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1');
|
||||||
})
|
})
|
||||||
obfs["ws-headers"] = result;
|
obfs["ws-headers"] = result;
|
||||||
}
|
}
|
||||||
ws_path = comma "ws-path" equals path:uri { obfs.path = path; }
|
ws_path = comma "ws-path" equals path:uri { obfs.path = path.trim().replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
|
||||||
|
|
||||||
obfs = comma "obfs" equals type:("http"/"tls") { obfs.type = type; }
|
obfs = comma "obfs" equals type:("http"/"tls") { obfs.type = type; }
|
||||||
obfs_host = comma "obfs-host" equals host:domain { obfs.host = host; };
|
obfs_host = comma "obfs-host" equals host:domain { obfs.host = host; };
|
||||||
|
|||||||
@@ -209,11 +209,11 @@ ws_headers = comma "ws-headers" equals headers:$[^,]+ {
|
|||||||
const result = {};
|
const result = {};
|
||||||
pairs.forEach(pair => {
|
pairs.forEach(pair => {
|
||||||
const [key, value] = pair.trim().split(":");
|
const [key, value] = pair.trim().split(":");
|
||||||
result[key.trim()] = value.trim();
|
result[key.trim()] = value.trim().replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1');
|
||||||
})
|
})
|
||||||
obfs["ws-headers"] = result;
|
obfs["ws-headers"] = result;
|
||||||
}
|
}
|
||||||
ws_path = comma "ws-path" equals path:uri { obfs.path = path; }
|
ws_path = comma "ws-path" equals path:uri { obfs.path = path.trim().replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
|
||||||
|
|
||||||
obfs = comma "obfs" equals type:("http"/"tls") { obfs.type = type; }
|
obfs = comma "obfs" equals type:("http"/"tls") { obfs.type = type; }
|
||||||
obfs_host = comma "obfs-host" equals host:domain { obfs.host = host; };
|
obfs_host = comma "obfs-host" equals host:domain { obfs.host = host; };
|
||||||
|
|||||||
@@ -119,10 +119,11 @@ export default function serve() {
|
|||||||
$app.start();
|
$app.start();
|
||||||
|
|
||||||
if ($.env.isNode) {
|
if ($.env.isNode) {
|
||||||
// Deprecated: SUB_STORE_BACKEND_CRON
|
// Deprecated: SUB_STORE_BACKEND_CRON, SUB_STORE_CRON
|
||||||
const backend_sync_cron =
|
const backend_sync_cron = eval(
|
||||||
eval('process.env.SUB_STORE_BACKEND_SYNC_CRON') ||
|
'process.env.SUB_STORE_BACKEND_SYNC_CRON',
|
||||||
eval('process.env.SUB_STORE_BACKEND_CRON');
|
);
|
||||||
|
|
||||||
if (backend_sync_cron) {
|
if (backend_sync_cron) {
|
||||||
$.info(`[SYNC CRON] ${backend_sync_cron} enabled`);
|
$.info(`[SYNC CRON] ${backend_sync_cron} enabled`);
|
||||||
const { CronJob } = eval(`require("cron")`);
|
const { CronJob } = eval(`require("cron")`);
|
||||||
@@ -145,6 +146,17 @@ export default function serve() {
|
|||||||
true, // start
|
true, // start
|
||||||
// 'Asia/Shanghai' // timeZone
|
// 'Asia/Shanghai' // timeZone
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
if (eval('process.env.SUB_STORE_BACKEND_CRON')) {
|
||||||
|
$.error(
|
||||||
|
`[SYNC CRON] SUB_STORE_BACKEND_CRON 已弃用, 请使用 SUB_STORE_BACKEND_SYNC_CRON`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (eval('process.env.SUB_STORE_CRON')) {
|
||||||
|
$.error(
|
||||||
|
`[SYNC CRON] SUB_STORE_CRON 已弃用, 请使用 SUB_STORE_BACKEND_SYNC_CRON`,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 格式: 0 */2 * * *,sub,a;0 */3 * * *,col,b
|
// 格式: 0 */2 * * *,sub,a;0 */3 * * *,col,b
|
||||||
// 每 2 小时处理一次单条订阅 a, 每 3 小时处理一次组合订阅 b
|
// 每 2 小时处理一次单条订阅 a, 每 3 小时处理一次组合订阅 b
|
||||||
|
|||||||
@@ -120,8 +120,10 @@ async function gistBackupAction(action) {
|
|||||||
switch (action) {
|
switch (action) {
|
||||||
case 'upload':
|
case 'upload':
|
||||||
try {
|
try {
|
||||||
content = $.read('#sub-store');
|
content = JSON.parse($.read('#sub-store'));
|
||||||
if ($.env.isNode) content = JSON.stringify($.cache, null, ` `);
|
if ($.env.isNode) content = JSON.parse(JSON.stringify($.cache));
|
||||||
|
content.settings.gistToken = '恢复后请重新设置 GitHub Token';
|
||||||
|
content = JSON.stringify(content, null, ` `);
|
||||||
$.info(`下载备份, 与本地内容对比...`);
|
$.info(`下载备份, 与本地内容对比...`);
|
||||||
const onlineContent = await gist.download(
|
const onlineContent = await gist.download(
|
||||||
GIST_BACKUP_FILE_NAME,
|
GIST_BACKUP_FILE_NAME,
|
||||||
@@ -137,8 +139,10 @@ async function gistBackupAction(action) {
|
|||||||
// update syncTime
|
// update syncTime
|
||||||
settings.syncTime = new Date().getTime();
|
settings.syncTime = new Date().getTime();
|
||||||
$.write(settings, SETTINGS_KEY);
|
$.write(settings, SETTINGS_KEY);
|
||||||
content = $.read('#sub-store');
|
content = JSON.parse($.read('#sub-store'));
|
||||||
if ($.env.isNode) content = JSON.stringify($.cache, null, ` `);
|
if ($.env.isNode) content = JSON.parse(JSON.stringify($.cache));
|
||||||
|
content.settings.gistToken = '恢复后请重新设置 GitHub Token';
|
||||||
|
content = JSON.stringify(content, null, ` `);
|
||||||
$.info(`上传备份中...`);
|
$.info(`上传备份中...`);
|
||||||
try {
|
try {
|
||||||
await gist.upload({
|
await gist.upload({
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ import $ from '@/core/app';
|
|||||||
import { findByName } from '@/utils/database';
|
import { findByName } from '@/utils/database';
|
||||||
import { produceArtifact } from '@/restful/sync';
|
import { produceArtifact } from '@/restful/sync';
|
||||||
import PROXY_PREPROCESSORS from '@/core/proxy-utils/preprocessors';
|
import PROXY_PREPROCESSORS from '@/core/proxy-utils/preprocessors';
|
||||||
|
import { ProxyUtils } from '@/core/proxy-utils';
|
||||||
|
|
||||||
const clashPreprocessor = PROXY_PREPROCESSORS.find(
|
const clashPreprocessor = PROXY_PREPROCESSORS.find(
|
||||||
(processor) => processor.name === 'Clash Pre-processor',
|
(processor) => processor.name === 'Clash Pre-processor',
|
||||||
);
|
);
|
||||||
@@ -261,10 +263,34 @@ export default async function download(
|
|||||||
if (shouldCache) {
|
if (shouldCache) {
|
||||||
resourceCache.set(id, body);
|
resourceCache.set(id, body);
|
||||||
if (customCacheKey) {
|
if (customCacheKey) {
|
||||||
$.info(
|
let shouldWriteCustomCacheKey = true;
|
||||||
`URL ${url}\n写入自定义缓存 ${$arguments?.cacheKey}`,
|
if (preprocess) {
|
||||||
);
|
try {
|
||||||
$.write(body, customCacheKey);
|
const proxies = ProxyUtils.parse(body);
|
||||||
|
if (
|
||||||
|
!Array.isArray(proxies) ||
|
||||||
|
proxies.length === 0
|
||||||
|
) {
|
||||||
|
$.error(
|
||||||
|
`URL ${url} 不包含有效节点\n不写入自定义缓存 ${$arguments?.cacheKey}`,
|
||||||
|
);
|
||||||
|
shouldWriteCustomCacheKey = false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
$.error(
|
||||||
|
`URL ${url} 尝试解析节点失败 ${
|
||||||
|
e.message ?? e
|
||||||
|
}\n不写入自定义缓存 ${$arguments?.cacheKey}`,
|
||||||
|
);
|
||||||
|
shouldWriteCustomCacheKey = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (shouldWriteCustomCacheKey) {
|
||||||
|
$.info(
|
||||||
|
`URL ${url}\n写入自定义缓存 ${$arguments?.cacheKey}`,
|
||||||
|
);
|
||||||
|
$.write(body, customCacheKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -334,7 +334,22 @@ export function normalizeFlowHeader(flowHeaders) {
|
|||||||
if (!kvMap.has(key)) {
|
if (!kvMap.has(key)) {
|
||||||
try {
|
try {
|
||||||
// 解码 URI 组件并保留原始值作为 fallback
|
// 解码 URI 组件并保留原始值作为 fallback
|
||||||
const decodedValue = decodeURIComponent(encodedValue);
|
let decodedValue = decodeURIComponent(encodedValue);
|
||||||
|
if (
|
||||||
|
['upload', 'download', 'total', 'expire'].includes(
|
||||||
|
key,
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
decodedValue = Number(decodedValue).toFixed(0);
|
||||||
|
} catch (e) {
|
||||||
|
$.error(
|
||||||
|
`Failed to convert value for key "${key}=${encodedValue}": ${
|
||||||
|
e.message ?? e
|
||||||
|
}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
kvMap.set(key, decodedValue);
|
kvMap.set(key, decodedValue);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
kvMap.set(key, encodedValue);
|
kvMap.set(key, encodedValue);
|
||||||
|
|||||||
53
backend/src/vendor/open-api.js
vendored
53
backend/src/vendor/open-api.js
vendored
@@ -18,6 +18,26 @@ function isPlainObject(obj) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseSocks5Uri(uri) {
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
let [__, username, password, server, port, query, name] = uri.match(
|
||||||
|
/^socks5:\/\/(?:(.*?):(.*?)@)?(.*?)(?::(\d+?))?(\?.*?)?(?:#(.*?))?$/,
|
||||||
|
);
|
||||||
|
if (port) {
|
||||||
|
port = parseInt(port, 10);
|
||||||
|
} else {
|
||||||
|
$.error(`port is not present in line: ${uri}`);
|
||||||
|
throw new Error(`port is not present in line: ${uri}`);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
type: 5,
|
||||||
|
host: server,
|
||||||
|
port,
|
||||||
|
|
||||||
|
userId: username != null ? decodeURIComponent(username) : undefined,
|
||||||
|
password: password != null ? decodeURIComponent(password) : undefined,
|
||||||
|
};
|
||||||
|
}
|
||||||
export class OpenAPI {
|
export class OpenAPI {
|
||||||
constructor(name = 'untitled', debug = false) {
|
constructor(name = 'untitled', debug = false) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@@ -393,6 +413,7 @@ export function HTTP(defaultOptions = { baseURL: '' }) {
|
|||||||
}
|
}
|
||||||
if (isNode) {
|
if (isNode) {
|
||||||
const undici = eval("require('undici')");
|
const undici = eval("require('undici')");
|
||||||
|
const { socksDispatcher } = eval("require('fetch-socks')");
|
||||||
const {
|
const {
|
||||||
ProxyAgent,
|
ProxyAgent,
|
||||||
EnvHttpProxyAgent,
|
EnvHttpProxyAgent,
|
||||||
@@ -422,16 +443,34 @@ export function HTTP(defaultOptions = { baseURL: '' }) {
|
|||||||
).toString('base64')}`,
|
).toString('base64')}`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
let dispatcher;
|
||||||
|
if (!opts.proxy) {
|
||||||
|
const allProxy =
|
||||||
|
eval('process.env.all_proxy') ||
|
||||||
|
eval('process.env.ALL_PROXY');
|
||||||
|
if (allProxy && /^socks5:\/\//.test(allProxy)) {
|
||||||
|
opts.proxy = allProxy;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (opts.proxy) {
|
||||||
|
if (/^socks5:\/\//.test(opts.proxy)) {
|
||||||
|
dispatcher = socksDispatcher(
|
||||||
|
parseSocks5Uri(opts.proxy),
|
||||||
|
agentOpts,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
dispatcher = new ProxyAgent({
|
||||||
|
...agentOpts,
|
||||||
|
uri: opts.proxy,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dispatcher = new EnvHttpProxyAgent(agentOpts);
|
||||||
|
}
|
||||||
const response = await request(opts.url, {
|
const response = await request(opts.url, {
|
||||||
...opts,
|
...opts,
|
||||||
method: method.toUpperCase(),
|
method: method.toUpperCase(),
|
||||||
dispatcher: (opts.proxy
|
dispatcher: dispatcher.compose(
|
||||||
? new ProxyAgent({
|
|
||||||
...agentOpts,
|
|
||||||
uri: opts.proxy,
|
|
||||||
})
|
|
||||||
: new EnvHttpProxyAgent(agentOpts)
|
|
||||||
).compose(
|
|
||||||
interceptors.redirect({
|
interceptors.redirect({
|
||||||
maxRedirections: 3,
|
maxRedirections: 3,
|
||||||
throwOnMaxRedirects: true,
|
throwOnMaxRedirects: true,
|
||||||
|
|||||||
@@ -247,14 +247,14 @@ function operator(proxies = [], targetPlatform, context) {
|
|||||||
// 这个历史遗留原因, 是有点复杂. 提供一个例子, 用来取当前脚本所在的组合订阅或单条订阅名称
|
// 这个历史遗留原因, 是有点复杂. 提供一个例子, 用来取当前脚本所在的组合订阅或单条订阅名称
|
||||||
|
|
||||||
// let name = ''
|
// let name = ''
|
||||||
// for (const [key, value] of Object.entries(env.source)) {
|
// for (const [key, value] of Object.entries(context.source)) {
|
||||||
// if (!key.startsWith('_')) {
|
// if (!key.startsWith('_')) {
|
||||||
// name = value.displayName || value.name
|
// name = value.displayName || value.name
|
||||||
// break
|
// break
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// if (!name) {
|
// if (!name) {
|
||||||
// const collection = env.source._collection
|
// const collection = context.source._collection
|
||||||
// name = collection.displayName || collection.name
|
// name = collection.displayName || collection.name
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user