cfpilot 0.8.0 → 0.8.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/assets/control.js +9 -9
- package/assets/dataplane.js +4 -4
- package/assets/worker.js +11 -11
- package/dist/cli.js +25 -7
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -87,7 +87,7 @@ var VERSION, NAME;
|
|
|
87
87
|
var init_version = __esm({
|
|
88
88
|
"src/shared/version.ts"() {
|
|
89
89
|
"use strict";
|
|
90
|
-
VERSION = "0.8.
|
|
90
|
+
VERSION = "0.8.1";
|
|
91
91
|
NAME = "cfpilot";
|
|
92
92
|
}
|
|
93
93
|
});
|
|
@@ -3555,6 +3555,24 @@ async function pool(items, concurrency, worker, shouldStop) {
|
|
|
3555
3555
|
await Promise.all(runners);
|
|
3556
3556
|
return out;
|
|
3557
3557
|
}
|
|
3558
|
+
async function poolAdaptive(items, concurrency, worker, batchSize = 200) {
|
|
3559
|
+
const out = [];
|
|
3560
|
+
const maxConcurrency = Math.max(1, concurrency);
|
|
3561
|
+
let current = maxConcurrency;
|
|
3562
|
+
for (let start = 0; start < items.length; start += batchSize) {
|
|
3563
|
+
const batch = items.slice(start, start + batchSize);
|
|
3564
|
+
const results = await pool(batch, current, worker);
|
|
3565
|
+
out.push(...results);
|
|
3566
|
+
const okCount = results.reduce((n, r) => n + (r.ok ? 1 : 0), 0);
|
|
3567
|
+
const rate = results.length > 0 ? okCount / results.length : 1;
|
|
3568
|
+
if (rate < 0.4) {
|
|
3569
|
+
current = Math.max(8, Math.floor(current / 2));
|
|
3570
|
+
} else if (rate > 0.85) {
|
|
3571
|
+
current = Math.min(maxConcurrency, current * 2);
|
|
3572
|
+
}
|
|
3573
|
+
}
|
|
3574
|
+
return out;
|
|
3575
|
+
}
|
|
3558
3576
|
function isTimeoutError(error) {
|
|
3559
3577
|
if (!error) return false;
|
|
3560
3578
|
return /超时|timeout|timed out|ETIMEDOUT/i.test(error);
|
|
@@ -3584,7 +3602,7 @@ async function runScan(options) {
|
|
|
3584
3602
|
const speedConcurrency = options.speedConcurrency ?? 4;
|
|
3585
3603
|
const speedTimeoutMs = options.speedTimeoutMs ?? 12e3;
|
|
3586
3604
|
const speedBytes = options.speedBytes ?? 5 * 1024 * 1024;
|
|
3587
|
-
const top = options.top ??
|
|
3605
|
+
const top = options.top ?? 8;
|
|
3588
3606
|
const countryFilter = normalizeCountryFilter(options.countries ?? []);
|
|
3589
3607
|
const hasCountryFilter = countryFilter.length > 0;
|
|
3590
3608
|
const effectiveProbeLimit = hasCountryFilter ? Math.max(probeLimit * 4, 500) : probeLimit;
|
|
@@ -3593,7 +3611,7 @@ async function runScan(options) {
|
|
|
3593
3611
|
});
|
|
3594
3612
|
report({ type: "stage", stage: 1, name: "TCP \u63E1\u624B\u521D\u7B5B", total: candidates.length });
|
|
3595
3613
|
let done = 0;
|
|
3596
|
-
const tcpResults = await
|
|
3614
|
+
const tcpResults = await poolAdaptive(candidates, concurrency, async (ip) => {
|
|
3597
3615
|
const result = await withRetry(retries, () => tcpPing(ip, options.port, tcpTimeoutMs));
|
|
3598
3616
|
done++;
|
|
3599
3617
|
if (done % 500 === 0 || done === candidates.length) {
|
|
@@ -3613,7 +3631,7 @@ async function runScan(options) {
|
|
|
3613
3631
|
const tlsInput = filtered.slice().sort((a, b) => a.latency - b.latency).slice(0, tlsCandidateLimit);
|
|
3614
3632
|
report({ type: "stage", stage: 1, name: "TLS \u63E1\u624B\u7B5B\u9009", total: tlsInput.length });
|
|
3615
3633
|
let tlsDone = 0;
|
|
3616
|
-
const tlsResults = await
|
|
3634
|
+
const tlsResults = await poolAdaptive(tlsInput, tlsConcurrency, async (item) => {
|
|
3617
3635
|
const probe = await withRetry(
|
|
3618
3636
|
retries,
|
|
3619
3637
|
() => probeTlsHandshake(item.ip, options.port, options.host, tlsTimeoutMs),
|
|
@@ -4741,7 +4759,7 @@ async function handleRequest(req, res) {
|
|
|
4741
4759
|
candidates: plan.candidates,
|
|
4742
4760
|
// 国家过滤(可多选):不传 = 全量;无效代码在 normalizeCountryFilter 里被丢弃
|
|
4743
4761
|
countries: Array.isArray(body.countries) ? body.countries : void 0,
|
|
4744
|
-
top: body.top ??
|
|
4762
|
+
top: body.top ?? 8,
|
|
4745
4763
|
// ⚠️ 必须透传这些参数,否则桥接服务永远用默认值:
|
|
4746
4764
|
// wsPath / probePath —— 对接第三方项目(路径不是 /__edge_probe)时,
|
|
4747
4765
|
// 阶段二会硬连默认探针路径 → 全军覆没
|
|
@@ -4882,7 +4900,7 @@ scan \u9009\u9879:
|
|
|
4882
4900
|
\uFF08\u9ED8\u8BA4\u6821\u9A8C\uFF1A\u53D1 PING \u5E76\u9A8C\u8BC1\u6570\u636E\u9762\u56DE {"pong":true}\uFF09
|
|
4883
4901
|
\u76EE\u6807\u6CA1\u6709\u63A2\u9488\u7AEF\u70B9\u65F6\u4F1A\u81EA\u52A8\u964D\u7EA7\u4E3A\u7EAF 101 \u6821\u9A8C
|
|
4884
4902
|
--no-speed \u8DF3\u8FC7\u6D4B\u901F\uFF0C\u53EA\u6309\u5EF6\u8FDF\u6392\u5E8F
|
|
4885
|
-
--top <n> \u8FD4\u56DE\u6761\u6570\uFF0C\u9ED8\u8BA4
|
|
4903
|
+
--top <n> \u8FD4\u56DE\u6761\u6570\uFF0C\u9ED8\u8BA4 8
|
|
4886
4904
|
--concurrency <n> \u9636\u6BB5\u4E00 TCP \u5E76\u53D1\uFF0C\u9ED8\u8BA4 300
|
|
4887
4905
|
--tls-concurrency <n> \u9636\u6BB5\u4E00 TLS \u63E1\u624B\u5E76\u53D1\uFF0C\u9ED8\u8BA4 64
|
|
4888
4906
|
TLS \u63E1\u624B\u662F CPU \u5BC6\u96C6\u578B\u64CD\u4F5C\uFF0C\u8FC7\u9AD8\u4F1A\u8BA9\u672C\u673A\u6210\u4E3A\u74F6\u9888
|
|
@@ -5059,7 +5077,7 @@ async function runScanCommand(args) {
|
|
|
5059
5077
|
process.exit(1);
|
|
5060
5078
|
}
|
|
5061
5079
|
const port = flagNumber(args, "port", 443);
|
|
5062
|
-
const top = flagNumber(args, "top",
|
|
5080
|
+
const top = flagNumber(args, "top", 8);
|
|
5063
5081
|
let token = flagString(args, "token");
|
|
5064
5082
|
const noCallback = flagBool(args, "no-callback");
|
|
5065
5083
|
const askCallback = flagBool(args, "ask-callback");
|