cfpilot 0.9.3 → 0.9.5
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 +10 -10
- package/assets/dataplane.js +5 -5
- package/assets/worker.js +15 -15
- package/dist/cli.js +155 -159
- 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.9.
|
|
90
|
+
VERSION = "0.9.5";
|
|
91
91
|
NAME = "cfpilot";
|
|
92
92
|
}
|
|
93
93
|
});
|
|
@@ -2831,7 +2831,11 @@ async function runDeployCommand(args) {
|
|
|
2831
2831
|
trojanPassword,
|
|
2832
2832
|
wsPath,
|
|
2833
2833
|
enableTrojan: true,
|
|
2834
|
-
|
|
2834
|
+
// XHTTP 默认开启(2026-10-28 用户要求):
|
|
2835
|
+
// 数据面上它只是多一条「必须带合法 VLESS 头」的 POST 路由,开了不影响安全;
|
|
2836
|
+
// 想关在面板「入站配置 → 启用服务端 XHTTP 入站监听」关即可
|
|
2837
|
+
//(KV 配置优先级高于环境变量,面板开关会覆盖这里的默认值)。
|
|
2838
|
+
enableXhttp: true,
|
|
2835
2839
|
mode,
|
|
2836
2840
|
keepCredentials,
|
|
2837
2841
|
skipSameVersion,
|
|
@@ -3505,118 +3509,6 @@ function probeTlsHandshake(ip, port, host, timeoutMs = 4e3) {
|
|
|
3505
3509
|
socket.on("error", (err) => finish({ error: err.message }));
|
|
3506
3510
|
});
|
|
3507
3511
|
}
|
|
3508
|
-
function measureDownload(ip, port, host, bytes, timeoutMs = 12e3, path = "/__edge_probe") {
|
|
3509
|
-
return new Promise((resolve2) => {
|
|
3510
|
-
const started = Date.now();
|
|
3511
|
-
let headerEnd = -1;
|
|
3512
|
-
let received = 0;
|
|
3513
|
-
let settled = false;
|
|
3514
|
-
let headerBuf = Buffer.alloc(0);
|
|
3515
|
-
let status2 = 0;
|
|
3516
|
-
const minPayload = Math.min(bytes, 32 * 1024);
|
|
3517
|
-
const finish = (result) => {
|
|
3518
|
-
if (settled) return;
|
|
3519
|
-
settled = true;
|
|
3520
|
-
clearTimeout(timer);
|
|
3521
|
-
try {
|
|
3522
|
-
socket.destroy();
|
|
3523
|
-
} catch {
|
|
3524
|
-
}
|
|
3525
|
-
resolve2({ ...result, ms: Date.now() - started });
|
|
3526
|
-
};
|
|
3527
|
-
const judge = () => {
|
|
3528
|
-
if (status2 !== 200) {
|
|
3529
|
-
return { ok: false, error: status2 === 0 ? "\u672A\u6536\u5230\u54CD\u5E94\u5934" : `HTTP ${status2}` };
|
|
3530
|
-
}
|
|
3531
|
-
if (received < minPayload) {
|
|
3532
|
-
return { ok: false, error: `\u8F7D\u8377\u4E0D\u8DB3\uFF08${received}/${minPayload} \u5B57\u8282\uFF09` };
|
|
3533
|
-
}
|
|
3534
|
-
return { ok: true };
|
|
3535
|
-
};
|
|
3536
|
-
const request = [
|
|
3537
|
-
`GET ${path}?bytes=${bytes} HTTP/1.1`,
|
|
3538
|
-
`Host: ${host}`,
|
|
3539
|
-
`User-Agent: ${USER_AGENT}`,
|
|
3540
|
-
"Accept: */*",
|
|
3541
|
-
"Accept-Encoding: identity",
|
|
3542
|
-
"",
|
|
3543
|
-
""
|
|
3544
|
-
].join("\r\n");
|
|
3545
|
-
const socket = tls.connect(
|
|
3546
|
-
{
|
|
3547
|
-
host: ip,
|
|
3548
|
-
port,
|
|
3549
|
-
servername: host,
|
|
3550
|
-
rejectUnauthorized: false,
|
|
3551
|
-
ALPNProtocols: ["http/1.1"]
|
|
3552
|
-
},
|
|
3553
|
-
() => {
|
|
3554
|
-
socket.write(request);
|
|
3555
|
-
}
|
|
3556
|
-
);
|
|
3557
|
-
const timer = setTimeout(() => {
|
|
3558
|
-
const seconds = Math.max(1e-3, (Date.now() - started) / 1e3);
|
|
3559
|
-
const v = judge();
|
|
3560
|
-
finish({
|
|
3561
|
-
ok: v.ok,
|
|
3562
|
-
bytes: received,
|
|
3563
|
-
speedMBps: v.ok ? received / 1024 / 1024 / seconds : 0,
|
|
3564
|
-
error: v.ok ? void 0 : v.error ?? "\u4E0B\u8F7D\u8D85\u65F6"
|
|
3565
|
-
});
|
|
3566
|
-
}, timeoutMs);
|
|
3567
|
-
socket.setTimeout(timeoutMs, () => {
|
|
3568
|
-
const seconds = Math.max(1e-3, (Date.now() - started) / 1e3);
|
|
3569
|
-
const v = judge();
|
|
3570
|
-
finish({
|
|
3571
|
-
ok: v.ok,
|
|
3572
|
-
bytes: received,
|
|
3573
|
-
speedMBps: v.ok ? received / 1024 / 1024 / seconds : 0,
|
|
3574
|
-
error: v.ok ? void 0 : v.error ?? "\u4E0B\u8F7D\u8D85\u65F6"
|
|
3575
|
-
});
|
|
3576
|
-
});
|
|
3577
|
-
socket.on("error", (err) => {
|
|
3578
|
-
finish({ ok: false, bytes: received, speedMBps: 0, error: err.message });
|
|
3579
|
-
});
|
|
3580
|
-
const settle = () => {
|
|
3581
|
-
if (settled) return;
|
|
3582
|
-
const seconds = Math.max(1e-3, (Date.now() - started) / 1e3);
|
|
3583
|
-
const v = judge();
|
|
3584
|
-
finish({
|
|
3585
|
-
ok: v.ok,
|
|
3586
|
-
bytes: received,
|
|
3587
|
-
speedMBps: v.ok ? received / 1024 / 1024 / seconds : 0,
|
|
3588
|
-
error: v.ok ? void 0 : v.error ?? "\u672A\u6536\u5230\u5B8C\u6574\u54CD\u5E94"
|
|
3589
|
-
});
|
|
3590
|
-
};
|
|
3591
|
-
socket.on("data", (chunk) => {
|
|
3592
|
-
if (headerEnd < 0) {
|
|
3593
|
-
headerBuf = headerBuf.length === 0 ? chunk : Buffer.concat([headerBuf, chunk]);
|
|
3594
|
-
const idx = headerBuf.indexOf("\r\n\r\n");
|
|
3595
|
-
if (idx < 0) {
|
|
3596
|
-
if (headerBuf.length > 8192) finish({ ok: false, bytes: 0, speedMBps: 0, error: "\u54CD\u5E94\u5934\u5F02\u5E38" });
|
|
3597
|
-
return;
|
|
3598
|
-
}
|
|
3599
|
-
const head = headerBuf.subarray(0, idx).toString("latin1");
|
|
3600
|
-
const code = /^HTTP\/1\.[01]\s+(\d{3})/.exec(head)?.[1];
|
|
3601
|
-
status2 = code ? Number(code) : 0;
|
|
3602
|
-
if (status2 !== 200) {
|
|
3603
|
-
finish({ ok: false, bytes: 0, speedMBps: 0, error: `HTTP ${status2 || "?"}` });
|
|
3604
|
-
return;
|
|
3605
|
-
}
|
|
3606
|
-
headerEnd = idx + 4;
|
|
3607
|
-
const body = headerBuf.subarray(headerEnd);
|
|
3608
|
-
received += body.byteLength;
|
|
3609
|
-
headerEnd = 0;
|
|
3610
|
-
headerBuf = Buffer.alloc(0);
|
|
3611
|
-
} else {
|
|
3612
|
-
received += chunk.byteLength;
|
|
3613
|
-
}
|
|
3614
|
-
if (received >= bytes) settle();
|
|
3615
|
-
});
|
|
3616
|
-
socket.on("end", settle);
|
|
3617
|
-
socket.on("close", settle);
|
|
3618
|
-
});
|
|
3619
|
-
}
|
|
3620
3512
|
function measureThroughput(options) {
|
|
3621
3513
|
const {
|
|
3622
3514
|
ip,
|
|
@@ -3628,18 +3520,18 @@ function measureThroughput(options) {
|
|
|
3628
3520
|
warmupMs = 1e3,
|
|
3629
3521
|
windowMs = 400,
|
|
3630
3522
|
connections = 3,
|
|
3631
|
-
timeoutMs = 2e4
|
|
3523
|
+
timeoutMs = 2e4,
|
|
3524
|
+
requiredHeader,
|
|
3525
|
+
minBytes = 32 * 1024
|
|
3632
3526
|
} = options;
|
|
3633
3527
|
const connCount = Math.max(1, Math.min(8, connections));
|
|
3634
3528
|
return new Promise((resolve2) => {
|
|
3635
3529
|
const started = Date.now();
|
|
3636
3530
|
let settled = false;
|
|
3637
|
-
|
|
3638
|
-
let windowBytes = 0;
|
|
3639
|
-
let windowStart = started;
|
|
3640
|
-
let peak = 0;
|
|
3531
|
+
const meter = new WindowMeter({ startedAt: started, warmupMs, windowMs });
|
|
3641
3532
|
let openedCount = 0;
|
|
3642
3533
|
let lastError = "";
|
|
3534
|
+
let headerMismatch = false;
|
|
3643
3535
|
const sockets = [];
|
|
3644
3536
|
const finish = () => {
|
|
3645
3537
|
if (settled) return;
|
|
@@ -3652,23 +3544,26 @@ function measureThroughput(options) {
|
|
|
3652
3544
|
} catch {
|
|
3653
3545
|
}
|
|
3654
3546
|
}
|
|
3655
|
-
const
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3547
|
+
const now = Date.now();
|
|
3548
|
+
const peakMBps = meter.finish(now);
|
|
3549
|
+
const totalBytes = meter.totalBytes;
|
|
3550
|
+
const elapsed = Math.max(1e-3, (now - started) / 1e3);
|
|
3551
|
+
const ok = !headerMismatch && totalBytes >= minBytes;
|
|
3552
|
+
let error;
|
|
3553
|
+
if (!ok) {
|
|
3554
|
+
if (headerMismatch) error = lastError || "\u76EE\u6807\u4E0D\u652F\u6301\u63A2\u9488\u6D4B\u901F";
|
|
3555
|
+
else if (totalBytes === 0) error = lastError || "\u672A\u6536\u5230\u6570\u636E";
|
|
3556
|
+
else error = lastError || `\u8F7D\u8377\u4E0D\u8DB3\uFF08${totalBytes}/${minBytes} \u5B57\u8282\uFF09`;
|
|
3662
3557
|
}
|
|
3663
|
-
const elapsed = Math.max(1e-3, (Date.now() - started) / 1e3);
|
|
3664
3558
|
resolve2({
|
|
3665
|
-
ok
|
|
3559
|
+
ok,
|
|
3666
3560
|
bytes: totalBytes,
|
|
3667
|
-
ms:
|
|
3668
|
-
|
|
3561
|
+
ms: now - started,
|
|
3562
|
+
steadyMBps: Number(meter.steadyMBps.toFixed(2)),
|
|
3563
|
+
peakMBps: Number(peakMBps.toFixed(2)),
|
|
3669
3564
|
avgMBps: Number((totalBytes / 1024 / 1024 / elapsed).toFixed(2)),
|
|
3670
3565
|
connections: openedCount,
|
|
3671
|
-
error
|
|
3566
|
+
error
|
|
3672
3567
|
});
|
|
3673
3568
|
};
|
|
3674
3569
|
const request = [
|
|
@@ -3725,14 +3620,19 @@ function measureThroughput(options) {
|
|
|
3725
3620
|
socket.destroy();
|
|
3726
3621
|
return;
|
|
3727
3622
|
}
|
|
3623
|
+
if (requiredHeader && !head.toLowerCase().includes(`${requiredHeader.toLowerCase()}:`)) {
|
|
3624
|
+
headerMismatch = true;
|
|
3625
|
+
lastError = `\u76EE\u6807\u4E0D\u652F\u6301\u63A2\u9488\u6D4B\u901F\uFF08\u54CD\u5E94\u5934\u7F3A\u5C11 ${requiredHeader}\uFF0C\u53EF\u6539\u7528 --speed-mode url\uFF09`;
|
|
3626
|
+
socket.destroy();
|
|
3627
|
+
finish();
|
|
3628
|
+
return;
|
|
3629
|
+
}
|
|
3728
3630
|
headerDone = true;
|
|
3729
3631
|
const body = headerBuffer.subarray(idx + 4);
|
|
3730
|
-
|
|
3731
|
-
windowBytes += body.byteLength;
|
|
3632
|
+
meter.add(body.byteLength);
|
|
3732
3633
|
headerBuffer = Buffer.alloc(0);
|
|
3733
3634
|
} else {
|
|
3734
|
-
|
|
3735
|
-
windowBytes += chunk.byteLength;
|
|
3635
|
+
meter.add(chunk.byteLength);
|
|
3736
3636
|
}
|
|
3737
3637
|
if (Date.now() - started > durationMs) finish();
|
|
3738
3638
|
});
|
|
@@ -3744,15 +3644,7 @@ function measureThroughput(options) {
|
|
|
3744
3644
|
});
|
|
3745
3645
|
};
|
|
3746
3646
|
const ticker = setInterval(() => {
|
|
3747
|
-
|
|
3748
|
-
const dt = (now - windowStart) / 1e3;
|
|
3749
|
-
if (dt <= 0) return;
|
|
3750
|
-
const bytes = windowBytes;
|
|
3751
|
-
windowBytes = 0;
|
|
3752
|
-
windowStart = now;
|
|
3753
|
-
if (now - started < warmupMs) return;
|
|
3754
|
-
const speed = bytes / dt / 1024 / 1024;
|
|
3755
|
-
if (speed > peak) peak = speed;
|
|
3647
|
+
meter.tick(Date.now());
|
|
3756
3648
|
}, windowMs);
|
|
3757
3649
|
const timer = setTimeout(finish, durationMs + 4e3);
|
|
3758
3650
|
for (let i = 0; i < connCount; i++) {
|
|
@@ -3760,10 +3652,101 @@ function measureThroughput(options) {
|
|
|
3760
3652
|
}
|
|
3761
3653
|
});
|
|
3762
3654
|
}
|
|
3763
|
-
|
|
3655
|
+
async function measureProbeThroughput(options) {
|
|
3656
|
+
const rawPath = options.path && options.path.length > 0 ? options.path : "/__edge_probe";
|
|
3657
|
+
const separator = rawPath.includes("?") ? "&" : "?";
|
|
3658
|
+
return await measureThroughput({
|
|
3659
|
+
ip: options.ip,
|
|
3660
|
+
port: options.port,
|
|
3661
|
+
sniHost: options.host,
|
|
3662
|
+
requestHost: options.host,
|
|
3663
|
+
path: `${rawPath}${separator}bytes=${options.bytes}`,
|
|
3664
|
+
connections: options.connections,
|
|
3665
|
+
durationMs: options.durationMs,
|
|
3666
|
+
warmupMs: options.warmupMs,
|
|
3667
|
+
windowMs: options.windowMs,
|
|
3668
|
+
timeoutMs: options.timeoutMs,
|
|
3669
|
+
// /__edge_probe 的独有标记:少了它就不是「我们自己的探针端点」
|
|
3670
|
+
requiredHeader: "x-probe-bytes",
|
|
3671
|
+
minBytes: 32 * 1024
|
|
3672
|
+
});
|
|
3673
|
+
}
|
|
3674
|
+
var WindowMeter, USER_AGENT;
|
|
3764
3675
|
var init_true_probe = __esm({
|
|
3765
3676
|
"src/scan/true-probe.ts"() {
|
|
3766
3677
|
"use strict";
|
|
3678
|
+
WindowMeter = class {
|
|
3679
|
+
startedAt;
|
|
3680
|
+
warmupMs;
|
|
3681
|
+
windowMs;
|
|
3682
|
+
windowBytes = 0;
|
|
3683
|
+
windowStart;
|
|
3684
|
+
peak = 0;
|
|
3685
|
+
total = 0;
|
|
3686
|
+
/** 预热之后累计的字节与**秒数**(注意 settle 里的 dt 已经是秒) */
|
|
3687
|
+
steadyBytes = 0;
|
|
3688
|
+
steadySeconds = 0;
|
|
3689
|
+
constructor(options) {
|
|
3690
|
+
this.startedAt = options.startedAt;
|
|
3691
|
+
this.warmupMs = options.warmupMs ?? 1e3;
|
|
3692
|
+
this.windowMs = options.windowMs ?? 500;
|
|
3693
|
+
this.windowStart = options.startedAt;
|
|
3694
|
+
}
|
|
3695
|
+
/** 累计收到的字节到当前窗口 */
|
|
3696
|
+
add(bytes) {
|
|
3697
|
+
if (bytes <= 0) return;
|
|
3698
|
+
this.windowBytes += bytes;
|
|
3699
|
+
this.total += bytes;
|
|
3700
|
+
}
|
|
3701
|
+
/** 结算当前窗口(由定时器按 windowMs 调用);返回当前峰值(MB/s) */
|
|
3702
|
+
tick(now) {
|
|
3703
|
+
this.settle(now);
|
|
3704
|
+
return this.peak;
|
|
3705
|
+
}
|
|
3706
|
+
/**
|
|
3707
|
+
* 收尾:结算最后一个不完整窗口,并处理「链路很快、没到预热期就下完预算」的兜底。
|
|
3708
|
+
*/
|
|
3709
|
+
finish(now) {
|
|
3710
|
+
this.settle(now);
|
|
3711
|
+
const elapsed = (now - this.startedAt) / 1e3;
|
|
3712
|
+
if (this.peak === 0 && this.total > 0 && elapsed > 0) {
|
|
3713
|
+
this.peak = this.total / 1024 / 1024 / elapsed;
|
|
3714
|
+
}
|
|
3715
|
+
this.windowBytes = 0;
|
|
3716
|
+
this.windowStart = now;
|
|
3717
|
+
return this.peak;
|
|
3718
|
+
}
|
|
3719
|
+
/** 结算一个窗口:慢启动期内只丢弃,不记峰值/稳态 */
|
|
3720
|
+
settle(now) {
|
|
3721
|
+
const dt = (now - this.windowStart) / 1e3;
|
|
3722
|
+
if (dt <= 0) return;
|
|
3723
|
+
const bytes = this.windowBytes;
|
|
3724
|
+
this.windowBytes = 0;
|
|
3725
|
+
this.windowStart = now;
|
|
3726
|
+
if (now - this.startedAt < this.warmupMs) return;
|
|
3727
|
+
this.steadyBytes += bytes;
|
|
3728
|
+
this.steadySeconds += dt;
|
|
3729
|
+
const speed = bytes / dt / 1024 / 1024;
|
|
3730
|
+
if (speed > this.peak) this.peak = speed;
|
|
3731
|
+
}
|
|
3732
|
+
/** 已接收总字节 */
|
|
3733
|
+
get totalBytes() {
|
|
3734
|
+
return this.total;
|
|
3735
|
+
}
|
|
3736
|
+
/** 当前峰值(MB/s) */
|
|
3737
|
+
get peakMBps() {
|
|
3738
|
+
return this.peak;
|
|
3739
|
+
}
|
|
3740
|
+
/**
|
|
3741
|
+
* 稳态吞吐(MB/s):预热之后按时长加权的平均。
|
|
3742
|
+
*
|
|
3743
|
+
* 若整段都在预热期(链路极快),退回整段平均 —— 否则会报 0。
|
|
3744
|
+
*/
|
|
3745
|
+
get steadyMBps() {
|
|
3746
|
+
if (this.steadySeconds > 0) return this.steadyBytes / 1024 / 1024 / this.steadySeconds;
|
|
3747
|
+
return this.peak;
|
|
3748
|
+
}
|
|
3749
|
+
};
|
|
3767
3750
|
USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36";
|
|
3768
3751
|
}
|
|
3769
3752
|
});
|
|
@@ -3977,7 +3960,7 @@ async function runScan(options) {
|
|
|
3977
3960
|
const probeConcurrency = options.probeConcurrency ?? 24;
|
|
3978
3961
|
const probeTimeoutMs = options.probeTimeoutMs ?? 3e3;
|
|
3979
3962
|
const speedLimit = options.speedLimit ?? 30;
|
|
3980
|
-
const speedConcurrency = options.speedConcurrency ??
|
|
3963
|
+
const speedConcurrency = options.speedConcurrency ?? 1;
|
|
3981
3964
|
const speedTimeoutMs = options.speedTimeoutMs ?? 12e3;
|
|
3982
3965
|
const speedBytes = options.speedBytes ?? 5 * 1024 * 1024;
|
|
3983
3966
|
const top = options.top ?? 8;
|
|
@@ -4134,31 +4117,33 @@ async function runScan(options) {
|
|
|
4134
4117
|
stage: 3,
|
|
4135
4118
|
done: speedDone,
|
|
4136
4119
|
total: stage2.length,
|
|
4137
|
-
message: `\u6D4B\u901F ${speedDone}/${stage2.length} ${result.
|
|
4120
|
+
message: `\u6D4B\u901F ${speedDone}/${stage2.length} ${result.steadyMBps.toFixed(1)} MB/s`
|
|
4138
4121
|
});
|
|
4139
|
-
return { ...item, speed: result.ok ? result.
|
|
4122
|
+
return { ...item, speed: result.ok ? result.steadyMBps : 0 };
|
|
4140
4123
|
});
|
|
4141
4124
|
} else {
|
|
4142
|
-
report({ type: "stage", stage: 3, name: "\u771F\u5B9E\u4E0B\u884C\u901F\u5EA6\u6D4B\u8BD5\uFF08\u9879\u76EE\u63A2\u9488\u7AEF\u70B9\uFF09", total: stage2.length });
|
|
4125
|
+
report({ type: "stage", stage: 3, name: "\u771F\u5B9E\u4E0B\u884C\u901F\u5EA6\u6D4B\u8BD5\uFF08\u9879\u76EE\u63A2\u9488\u7AEF\u70B9 \xB7 \u591A\u6D41\u7A33\u6001\uFF09", total: stage2.length });
|
|
4143
4126
|
let speedDone = 0;
|
|
4144
4127
|
speedResults = await pool(stage2, speedConcurrency, async (item) => {
|
|
4145
|
-
const result = await
|
|
4146
|
-
item.ip,
|
|
4147
|
-
options.port,
|
|
4148
|
-
options.host,
|
|
4149
|
-
speedBytes,
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4128
|
+
const result = await measureProbeThroughput({
|
|
4129
|
+
ip: item.ip,
|
|
4130
|
+
port: options.port,
|
|
4131
|
+
host: options.host,
|
|
4132
|
+
bytes: speedBytes,
|
|
4133
|
+
path: strictProbePath,
|
|
4134
|
+
connections: options.speedConnections ?? 3,
|
|
4135
|
+
durationMs: options.speedDurationMs ?? 6e3,
|
|
4136
|
+
timeoutMs: speedTimeoutMs
|
|
4137
|
+
});
|
|
4153
4138
|
speedDone++;
|
|
4154
4139
|
report({
|
|
4155
4140
|
type: "progress",
|
|
4156
4141
|
stage: 3,
|
|
4157
4142
|
done: speedDone,
|
|
4158
4143
|
total: stage2.length,
|
|
4159
|
-
message: `\u6D4B\u901F ${speedDone}/${stage2.length} ${result.
|
|
4144
|
+
message: `\u6D4B\u901F ${speedDone}/${stage2.length} ${result.steadyMBps.toFixed(1)} MB/s`
|
|
4160
4145
|
});
|
|
4161
|
-
return { ...item, speed: result.ok ? result.
|
|
4146
|
+
return { ...item, speed: result.ok ? result.steadyMBps : 0 };
|
|
4162
4147
|
});
|
|
4163
4148
|
}
|
|
4164
4149
|
const entries = speedResults.filter((r) => options.skipSpeed ? true : Boolean(r.speed && r.speed > 0)).map((r) => ({
|
|
@@ -5272,6 +5257,15 @@ scan \u9009\u9879:
|
|
|
5272
5257
|
--speed-conns <n> \u6D4B\u901F\u5E76\u53D1\u8FDE\u63A5\u6570\uFF0C\u9ED8\u8BA4 3
|
|
5273
5258
|
\u5355\u6761 TCP \u8FDE\u63A5\u53D7\u62E5\u585E\u7A97\u53E3\u9650\u5236\uFF0C\u591A\u8FDE\u63A5\u66F4\u63A5\u8FD1\u771F\u5B9E\u5E26\u5BBD
|
|
5274
5259
|
--speed-duration <ms> \u6D4B\u901F\u65F6\u957F\uFF0C\u9ED8\u8BA4 6000
|
|
5260
|
+
\u524D 1 \u79D2\u7684\u6162\u542F\u52A8\u6837\u672C\u4F1A\u88AB\u4E22\u5F03\uFF0C\u53EA\u7EDF\u8BA1\u4E4B\u540E\u7684\u7A33\u6001\u541E\u5410
|
|
5261
|
+
\u26A0\uFE0F \u6D41\u91CF\u5F00\u9500 \u2248 \u65F6\u957F \xD7 \u94FE\u8DEF\u901F\u7387 \xD7 \u8FDE\u63A5\u6570\uFF1A
|
|
5262
|
+
3 \u6761\u8FDE\u63A5\u30016 \u79D2\u30011MB/s \u94FE\u8DEF\u4E0A\u7EA6 15MB/\u5019\u9009
|
|
5263
|
+
\uFF0830 \u4E2A\u5019\u9009 \u2248 450MB\uFF09\u3002\u6D41\u91CF\u654F\u611F\u65F6\u8C03\u5C0F\u5B83\u6216 --speed-limit
|
|
5264
|
+
--speed-concurrency <n>
|
|
5265
|
+
\u6D4B\u901F\u9636\u6BB5\u7684\u5019\u9009\u5E76\u884C\u6570\uFF0C\u9ED8\u8BA4 1\uFF08\u4E32\u884C\uFF09
|
|
5266
|
+
\u5E26\u5BBD\u7531\u6574\u6761\u94FE\u8DEF\u5171\u4EAB\uFF1A\u5E76\u884C\u6D4B\u591A\u4E2A\u5019\u9009\u4F1A\u4E92\u76F8\u62A2\u5E26\u5BBD\uFF0C
|
|
5267
|
+
\u6BCF\u4E2A\u90FD\u53EA\u80FD\u6D4B\u5230 1/N\uFF0C\u6570\u503C\u666E\u904D\u504F\u4F4E\uFF08\u8001\u7248\u672C\u62A5\u51FA
|
|
5268
|
+
0.1 MB/s \u7684\u4E3B\u56E0\uFF09\u3002>1 \u53EA\u5728\u5343\u5146\u4EE5\u4E0A\u94FE\u8DEF\u624D\u6709\u610F\u4E49
|
|
5275
5269
|
--retries <n> \u6BCF\u4E2A\u63A2\u6D4B\u7684\u5C1D\u8BD5\u6B21\u6570\uFF08\u542B\u9996\u6B21\uFF09\uFF0C\u9ED8\u8BA4 2
|
|
5276
5270
|
\u771F\u673A\u5076\u53D1\u5931\u8D25\u7387 3~5%\uFF0C\u91CD\u8BD5\u53D6\u7B2C\u4E00\u6B21\u6210\u529F\u7684\u7ED3\u679C
|
|
5277
5271
|
--no-verify \u9636\u6BB5\u4E8C\u53EA\u505A 101 \u63E1\u624B\uFF0C\u8DF3\u8FC7\u54CD\u5E94\u4F53\u6821\u9A8C
|
|
@@ -5607,6 +5601,8 @@ ${NAME} v${VERSION}
|
|
|
5607
5601
|
speedBytes: flagNumber(args, "speed-bytes", 5 * 1024 * 1024),
|
|
5608
5602
|
speedMode,
|
|
5609
5603
|
speedUrl,
|
|
5604
|
+
// 默认串行:带宽是共享资源,并行测多个候选会互相抢带宽(见 scan.ts 的 speedConcurrency 注释)
|
|
5605
|
+
speedConcurrency: flagNumber(args, "speed-concurrency", 1),
|
|
5610
5606
|
speedConnections: flagNumber(args, "speed-conns", 3),
|
|
5611
5607
|
speedDurationMs: flagNumber(args, "speed-duration", 6e3),
|
|
5612
5608
|
top,
|