mihomo-cli 2.4.0 → 2.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/README.md +1 -1
- package/dist/index.js +40 -44
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.4.2] - 2026-05-02
|
|
4
|
+
|
|
5
|
+
### 改进
|
|
6
|
+
|
|
7
|
+
- 自动清理阈值统一为 50 个节点(不再区分订阅类型)
|
|
8
|
+
- 订阅默认更新间隔从 12 小时缩短为 4 小时
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## [2.4.1] - 2026-05-02
|
|
13
|
+
|
|
14
|
+
### 修复
|
|
15
|
+
|
|
16
|
+
- 启动时清除代理环境变量(`http_proxy` / `https_proxy` / `all_proxy`),避免系统已有代理导致请求异常
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
3
20
|
## [2.4.0] - 2026-05-02
|
|
4
21
|
|
|
5
22
|
### 新功能
|
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -3509,48 +3509,37 @@ function parseProxyUris(content) {
|
|
|
3509
3509
|
return proxies;
|
|
3510
3510
|
}
|
|
3511
3511
|
async function downloadAllSources(sources, onProgress) {
|
|
3512
|
-
const
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
const entry = { name: source.name, url: source.url, proxies: [], proxyGroups: 0 };
|
|
3512
|
+
const client = createHttpClient({ timeout: 3e4 });
|
|
3513
|
+
const tasks = sources.map(async (source) => {
|
|
3514
|
+
const entry = { name: source.name, url: source.url, proxies: [], proxyGroups: 0 };
|
|
3515
|
+
try {
|
|
3516
|
+
const response = await client.get(source.url, { responseType: "text" });
|
|
3517
|
+
const content = response.data;
|
|
3518
|
+
if (!content?.trim()) throw new Error("\u5185\u5BB9\u4E3A\u7A7A");
|
|
3519
|
+
let proxies;
|
|
3521
3520
|
try {
|
|
3522
|
-
const
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
const decoded = tryDecodeBase64Content(content);
|
|
3533
|
-
if (decoded) {
|
|
3534
|
-
proxies = parseProxyUris(decoded);
|
|
3535
|
-
} else {
|
|
3536
|
-
proxies = parseProxyUris(content);
|
|
3537
|
-
}
|
|
3538
|
-
if (proxies.length === 0) throw new Error("\u65E0\u6CD5\u89E3\u6790\u8BA2\u9605\u5185\u5BB9\uFF08\u975E YAML/JSON/Base64\uFF09");
|
|
3521
|
+
const parsed = parseYamlOrJson(content, "\u8BA2\u9605\u5185\u5BB9");
|
|
3522
|
+
proxies = parsed.proxies || [];
|
|
3523
|
+
const groups = parsed["proxy-groups"];
|
|
3524
|
+
if (groups) entry.proxyGroups = groups.length;
|
|
3525
|
+
} catch {
|
|
3526
|
+
const decoded = tryDecodeBase64Content(content);
|
|
3527
|
+
if (decoded) {
|
|
3528
|
+
proxies = parseProxyUris(decoded);
|
|
3529
|
+
} else {
|
|
3530
|
+
proxies = parseProxyUris(content);
|
|
3539
3531
|
}
|
|
3540
|
-
|
|
3541
|
-
onProgress?.(source.name, true, proxies.length, entry.proxyGroups);
|
|
3542
|
-
} catch (e) {
|
|
3543
|
-
entry.error = e.message;
|
|
3544
|
-
onProgress?.(source.name, false, 0, 0, entry.error);
|
|
3532
|
+
if (proxies.length === 0) throw new Error("\u65E0\u6CD5\u89E3\u6790\u8BA2\u9605\u5185\u5BB9\uFF08\u975E YAML/JSON/Base64\uFF09");
|
|
3545
3533
|
}
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
if (val !== void 0) process.env[key] = val;
|
|
3534
|
+
entry.proxies = proxies.map((p) => ({ ...p, name: `[${source.name}] ${p.name}` }));
|
|
3535
|
+
onProgress?.(source.name, true, proxies.length, entry.proxyGroups);
|
|
3536
|
+
} catch (e) {
|
|
3537
|
+
entry.error = e.message;
|
|
3538
|
+
onProgress?.(source.name, false, 0, 0, entry.error);
|
|
3552
3539
|
}
|
|
3553
|
-
|
|
3540
|
+
return entry;
|
|
3541
|
+
});
|
|
3542
|
+
return await Promise.all(tasks);
|
|
3554
3543
|
}
|
|
3555
3544
|
function isProxyValid(proxy) {
|
|
3556
3545
|
if (!proxy.name || !proxy.server || !proxy.port) return false;
|
|
@@ -4222,7 +4211,7 @@ function viewLogWithTail(logPath, options) {
|
|
|
4222
4211
|
}
|
|
4223
4212
|
|
|
4224
4213
|
// src/subscription.ts
|
|
4225
|
-
var DEFAULT_UPDATE_INTERVAL_HOURS =
|
|
4214
|
+
var DEFAULT_UPDATE_INTERVAL_HOURS = 4;
|
|
4226
4215
|
var YAML_DUMP_OPTS = { indent: 2, lineWidth: -1, noCompatMode: true };
|
|
4227
4216
|
var HTTP_CLIENT = createHttpClient({ timeout: 6e4 });
|
|
4228
4217
|
function isMultiUrl(url) {
|
|
@@ -4667,8 +4656,7 @@ function printStatus() {
|
|
|
4667
4656
|
}
|
|
4668
4657
|
|
|
4669
4658
|
// src/commands/start.ts
|
|
4670
|
-
var AUTO_CLEAN_THRESHOLD =
|
|
4671
|
-
var AUTO_CLEAN_THRESHOLD_FREE = 50;
|
|
4659
|
+
var AUTO_CLEAN_THRESHOLD = 50;
|
|
4672
4660
|
function handleStopResult(result) {
|
|
4673
4661
|
if (result.remaining && result.remaining.length > 0) {
|
|
4674
4662
|
console.error(`${colors.red("\u90E8\u5206\u8FDB\u7A0B\u672A\u7EC8\u6B62:")} ${result.remaining.join(", ")}`);
|
|
@@ -4720,10 +4708,9 @@ async function cmdStart(args) {
|
|
|
4720
4708
|
}
|
|
4721
4709
|
process.exit(1);
|
|
4722
4710
|
}
|
|
4723
|
-
|
|
4724
|
-
if (configInfo.proxies > cleanThreshold) {
|
|
4711
|
+
if (configInfo.proxies > AUTO_CLEAN_THRESHOLD) {
|
|
4725
4712
|
console.log("");
|
|
4726
|
-
console.log(`\u8282\u70B9\u6570 ${configInfo.proxies} \u8D85\u8FC7 ${
|
|
4713
|
+
console.log(`\u8282\u70B9\u6570 ${configInfo.proxies} \u8D85\u8FC7 ${AUTO_CLEAN_THRESHOLD}\uFF0C\u81EA\u52A8\u6E05\u7406...`);
|
|
4727
4714
|
console.log("");
|
|
4728
4715
|
await sleep(1e3);
|
|
4729
4716
|
const cleanResult = await autoCleanSubscription(sub.name, { onResult: printTestResult });
|
|
@@ -6174,7 +6161,16 @@ process.on("unhandledRejection", (reason) => {
|
|
|
6174
6161
|
\u672A\u5904\u7406\u7684 Promise \u62D2\u7EDD: ${msg}`);
|
|
6175
6162
|
process.exit(1);
|
|
6176
6163
|
});
|
|
6164
|
+
function clearProxyEnv() {
|
|
6165
|
+
delete process.env.http_proxy;
|
|
6166
|
+
delete process.env.https_proxy;
|
|
6167
|
+
delete process.env.HTTP_PROXY;
|
|
6168
|
+
delete process.env.HTTPS_PROXY;
|
|
6169
|
+
delete process.env.all_proxy;
|
|
6170
|
+
delete process.env.ALL_PROXY;
|
|
6171
|
+
}
|
|
6177
6172
|
async function main() {
|
|
6173
|
+
clearProxyEnv();
|
|
6178
6174
|
ensureDirs();
|
|
6179
6175
|
const args = process.argv.slice(2);
|
|
6180
6176
|
if (args.length === 0) {
|