mihomo-cli 2.2.0 → 2.2.1
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 +9 -0
- package/dist/index.js +23 -12
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -4293,6 +4293,7 @@ function loadSubscriptionConfig(subName) {
|
|
|
4293
4293
|
};
|
|
4294
4294
|
}
|
|
4295
4295
|
function saveSubscriptionConfig(subName, parsed) {
|
|
4296
|
+
shortenProxyNames(parsed);
|
|
4296
4297
|
parsed.raw.proxies = parsed.proxies;
|
|
4297
4298
|
parsed.raw["proxy-groups"] = parsed.proxyGroups;
|
|
4298
4299
|
saveSubscriptionRawConfig(subName, jsYaml.dump(parsed.raw, YAML_DUMP_OPTS));
|
|
@@ -4571,21 +4572,26 @@ function cleanDeadProxies(parsed, deadNames) {
|
|
|
4571
4572
|
}
|
|
4572
4573
|
async function autoCleanSubscription(subName, options = {}) {
|
|
4573
4574
|
const parsed = loadSubscriptionConfig(subName);
|
|
4574
|
-
shortenProxyNames(parsed);
|
|
4575
|
-
saveSubscriptionConfig(subName, parsed);
|
|
4576
4575
|
const summary = await testSubscriptionProxies(subName, { ...options, parsed });
|
|
4577
4576
|
let removedProxies = 0;
|
|
4578
4577
|
let updatedGroups = 0;
|
|
4579
4578
|
let removedGroups = 0;
|
|
4579
|
+
let skipped = false;
|
|
4580
4580
|
if (summary.dead > 0) {
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4581
|
+
if (summary.alive === 0 || summary.alive / summary.total < 0.01) {
|
|
4582
|
+
skipped = true;
|
|
4583
|
+
} else {
|
|
4584
|
+
const deadNames = new Set(summary.results.filter((r) => r.delay === null).map((r) => r.name));
|
|
4585
|
+
const cleanResult = cleanDeadProxies(parsed, deadNames);
|
|
4586
|
+
removedProxies = cleanResult.removedProxies;
|
|
4587
|
+
updatedGroups = cleanResult.updatedGroups;
|
|
4588
|
+
removedGroups = cleanResult.removedGroups;
|
|
4589
|
+
}
|
|
4590
|
+
}
|
|
4591
|
+
if (!skipped) {
|
|
4586
4592
|
saveSubscriptionConfig(subName, parsed);
|
|
4587
4593
|
}
|
|
4588
|
-
return { summary, removedProxies, updatedGroups, removedGroups };
|
|
4594
|
+
return { summary, removedProxies, updatedGroups, removedGroups, skipped };
|
|
4589
4595
|
}
|
|
4590
4596
|
|
|
4591
4597
|
// src/commands/status.ts
|
|
@@ -4921,11 +4927,14 @@ async function cmdSubscription(args) {
|
|
|
4921
4927
|
});
|
|
4922
4928
|
console.log("");
|
|
4923
4929
|
console.log(formatTestSummary(result.summary));
|
|
4924
|
-
if (result.
|
|
4930
|
+
if (result.skipped) {
|
|
4931
|
+
console.log("");
|
|
4932
|
+
console.log(colors.yellow("\u5B58\u6D3B\u8282\u70B9\u4E0D\u8DB3 1%\uFF0C\u8DF3\u8FC7\u6E05\u7406\u3002\u8BF7\u68C0\u67E5\u539F\u59CB\u8BA2\u9605\u662F\u5426\u6709\u6548"));
|
|
4933
|
+
} else if (result.removedProxies > 0) {
|
|
4925
4934
|
console.log(`${colors.green("\u5DF2\u6E05\u7406")}: ${formatCleanSummary(result)}`);
|
|
4935
|
+
console.log("");
|
|
4936
|
+
console.log("\u63D0\u793A: \u9700\u8981\u91CD\u542F mihomo \u4F7F\u66F4\u6539\u751F\u6548 (mihomo start)");
|
|
4926
4937
|
}
|
|
4927
|
-
console.log("");
|
|
4928
|
-
console.log("\u63D0\u793A: \u9700\u8981\u91CD\u542F mihomo \u4F7F\u66F4\u6539\u751F\u6548 (mihomo start)");
|
|
4929
4938
|
return;
|
|
4930
4939
|
}
|
|
4931
4940
|
if (action === "test") {
|
|
@@ -5003,7 +5012,9 @@ async function cmdStart(args) {
|
|
|
5003
5012
|
const cleanResult = await autoCleanSubscription(sub.name, { onResult: printTestResult });
|
|
5004
5013
|
console.log("");
|
|
5005
5014
|
console.log(formatTestSummary(cleanResult.summary));
|
|
5006
|
-
if (cleanResult.
|
|
5015
|
+
if (cleanResult.skipped) {
|
|
5016
|
+
console.log(colors.yellow("\u5B58\u6D3B\u8282\u70B9\u4E0D\u8DB3 1%\uFF0C\u8DF3\u8FC7\u6E05\u7406\u3002\u8BF7\u68C0\u67E5\u539F\u59CB\u8BA2\u9605\u662F\u5426\u6709\u6548"));
|
|
5017
|
+
} else if (cleanResult.removedProxies > 0) {
|
|
5007
5018
|
console.log(`${colors.green("\u5DF2\u6E05\u7406")}: ${formatCleanSummary(cleanResult)}`);
|
|
5008
5019
|
console.log("");
|
|
5009
5020
|
console.log("\u91CD\u65B0\u52A0\u8F7D\u914D\u7F6E...");
|