cfpilot 0.18.0 → 0.30.0
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 +12 -13
- package/assets/dataplane.js +5 -5
- package/assets/worker.js +18 -22
- package/dist/cli.js +40 -6
- 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.
|
|
90
|
+
VERSION = "0.30.0";
|
|
91
91
|
NAME = "cfpilot";
|
|
92
92
|
}
|
|
93
93
|
});
|
|
@@ -5523,6 +5523,10 @@ async function runScan(options) {
|
|
|
5523
5523
|
const speedTimeoutMs = options.speedTimeoutMs ?? 12e3;
|
|
5524
5524
|
const speedBytes = options.speedBytes ?? 5 * 1024 * 1024;
|
|
5525
5525
|
const top = options.top ?? 8;
|
|
5526
|
+
const minSpeedMBps = options.minSpeedMBps ?? 0;
|
|
5527
|
+
if (minSpeedMBps > 0 && options.skipSpeed) {
|
|
5528
|
+
throw new Error("--min-speed \u4E0E\u300C\u8DF3\u8FC7\u6D4B\u901F\u300D\u4E92\u65A5\uFF1A\u8DF3\u8FC7\u6D4B\u901F\u65F6\u6CA1\u6709\u901F\u5EA6\u503C\u53EF\u7528\u4E8E\u7B5B\u9009");
|
|
5529
|
+
}
|
|
5526
5530
|
const countryFilter = normalizeCountryFilter(options.countries ?? []);
|
|
5527
5531
|
const hasCountryFilter = countryFilter.length > 0;
|
|
5528
5532
|
const effectiveProbeLimit = hasCountryFilter ? Math.max(probeLimit * 4, 500) : probeLimit;
|
|
@@ -5890,7 +5894,17 @@ async function runScan(options) {
|
|
|
5890
5894
|
})).sort(
|
|
5891
5895
|
(a, b) => options.skipSpeed ? a.tlsMs - b.tlsMs || a.latency - b.latency : b.speed - a.speed || a.tlsMs - b.tlsMs || a.latency - b.latency
|
|
5892
5896
|
);
|
|
5893
|
-
const
|
|
5897
|
+
const speedFiltered = filterByMinSpeed(ranked, minSpeedMBps);
|
|
5898
|
+
if (minSpeedMBps > 0 && speedFiltered.length < ranked.length) {
|
|
5899
|
+
report({
|
|
5900
|
+
type: "progress",
|
|
5901
|
+
stage: 3,
|
|
5902
|
+
done: speedFiltered.length,
|
|
5903
|
+
total: ranked.length,
|
|
5904
|
+
message: `\u901F\u5EA6\u8FC7\u6EE4\uFF1A\u6DD8\u6C70 ${ranked.length - speedFiltered.length} \u4E2A\u4F4E\u4E8E ${minSpeedMBps} MB/s \u7684\u5019\u9009`
|
|
5905
|
+
});
|
|
5906
|
+
}
|
|
5907
|
+
const entries = pickWithDiversity(speedFiltered, top);
|
|
5894
5908
|
if (options.unlock && options.uuid && entries.length > 0) {
|
|
5895
5909
|
const byColo = /* @__PURE__ */ new Map();
|
|
5896
5910
|
for (const entry of entries) {
|
|
@@ -6074,6 +6088,10 @@ async function coarsePreRank(options, candidates, speedLimit, report, probePath)
|
|
|
6074
6088
|
});
|
|
6075
6089
|
return rankByCoarseSpeed(candidates, coarse, speedLimit);
|
|
6076
6090
|
}
|
|
6091
|
+
function filterByMinSpeed(entries, minSpeedMBps) {
|
|
6092
|
+
if (!(minSpeedMBps > 0)) return entries;
|
|
6093
|
+
return entries.filter((e) => e.speed >= minSpeedMBps);
|
|
6094
|
+
}
|
|
6077
6095
|
function pickWithDiversity(ranked, top) {
|
|
6078
6096
|
if (top <= 0) return [];
|
|
6079
6097
|
const v4 = ranked.filter((item) => !item.ip.includes(":"));
|
|
@@ -7382,7 +7400,7 @@ async function resolveScanCandidates(body) {
|
|
|
7382
7400
|
return { candidates: plan.candidates, source: "generated", family: plan.family, note: plan.note };
|
|
7383
7401
|
}
|
|
7384
7402
|
function describePlan(plan) {
|
|
7385
|
-
if (plan.source === "manual") return `\u4F7F\u7528\
|
|
7403
|
+
if (plan.source === "manual") return `\u4F7F\u7528\u624B\u52A8\u6307\u5B9A\u7684 ${plan.candidates.length} \u4E2A\u5019\u9009 IP`;
|
|
7386
7404
|
if (plan.source === "request") return `\u4F7F\u7528\u8BF7\u6C42\u643A\u5E26\u7684 ${plan.candidates.length} \u4E2A\u5019\u9009 IP`;
|
|
7387
7405
|
const note = plan.note ? `\uFF08${plan.note}\uFF09` : "";
|
|
7388
7406
|
return `\u5DF2\u81EA\u52A8\u751F\u6210 ${plan.candidates.length} \u4E2A\u5019\u9009 IP${note}`;
|
|
@@ -7612,7 +7630,7 @@ async function handleRequest(req, res) {
|
|
|
7612
7630
|
// 阶段二会硬连默认探针路径 → 全军覆没
|
|
7613
7631
|
// verifyPayload —— 目标没有探针端点时,内容校验必然失败,
|
|
7614
7632
|
// 应自动退回纯 101 校验
|
|
7615
|
-
// speedMode / speedUrl ——
|
|
7633
|
+
// speedMode / speedUrl —— 调用方可以指定用探针端点还是公开测速地址
|
|
7616
7634
|
probeTransport: body.probeTransport,
|
|
7617
7635
|
xhttpPath: body.xhttpPath,
|
|
7618
7636
|
wsPath: body.wsPath,
|
|
@@ -7717,7 +7735,7 @@ CFPilot \u672C\u5730\u771F\u8FDE\u63A5\u4F18\u9009\u5668 \u2014\u2014 \u7528\u4F
|
|
|
7717
7735
|
${NAME} scan [\u9009\u9879] \u6267\u884C\u4E09\u9636\u4F18\u9009\u626B\u63CF
|
|
7718
7736
|
${NAME} scan compare \u53CC\u6808\u5BF9\u7167\u62A5\u544A\uFF08IPv4 vs IPv6\uFF0C\u540C\u53C2\u6570\u8DD1\u4E24\u8F6E\uFF09
|
|
7719
7737
|
${NAME} scan relay \u53CD\u4EE3\u5165\u53E3\u5019\u9009\u7684\u51FA\u7AD9\u4F53\u68C0\uFF08\u4ECE Worker \u5185\u90E8\u53D1\u8D77\uFF09
|
|
7720
|
-
${NAME} scan serve [\u9009\u9879] \u542F\u52A8\u672C\u5730\u6865\u63A5\u670D\u52A1\
|
|
7738
|
+
${NAME} scan serve [\u9009\u9879] \u542F\u52A8\u672C\u5730\u6865\u63A5\u670D\u52A1\uFF08HTTP \u63A5\u53E3\uFF0C\u4F9B\u811A\u672C\u9A71\u52A8\u626B\u63CF\uFF09
|
|
7721
7739
|
${NAME} scan ips [\u9009\u9879] \u6253\u5370 Cloudflare \u5B98\u65B9\u7F51\u6BB5
|
|
7722
7740
|
${NAME} --help \u663E\u793A\u5E2E\u52A9
|
|
7723
7741
|
${NAME} --version \u663E\u793A\u7248\u672C
|
|
@@ -7804,6 +7822,12 @@ scan \u9009\u9879:
|
|
|
7804
7822
|
\u5E26\u6B64\u53C2\u6570\u4F1A\u81EA\u52A8\u6269\u5927 101 \u6821\u9A8C\u7684\u5019\u9009\u6C60\uFF08120 \u2192 \u6700\u591A 500\uFF09\uFF0C
|
|
7805
7823
|
\u5426\u5219\u76EE\u6807\u5730\u533A\u53EF\u80FD\u56E0\u5EF6\u8FDF\u6392\u5E8F\u88AB\u63D0\u524D\u622A\u65AD\uFF1B
|
|
7806
7824
|
\u7B5B\u4E0D\u5230\u65F6\u4F1A\u660E\u786E\u63D0\u793A\u300C\u5DF2\u653E\u5BBD\u4E3A\u5168\u91CF\u300D\u800C\u4E0D\u662F\u9759\u9ED8\u5FFD\u7565
|
|
7825
|
+
--min-speed <MB/s> \u4E0B\u884C\u901F\u5EA6\u4E0B\u9650\uFF0C\u9ED8\u8BA4 0\uFF08\u4E0D\u8FC7\u6EE4\uFF09
|
|
7826
|
+
\u6309**\u7A33\u6001**\u4E0B\u884C\u901F\u5EA6\u6DD8\u6C70\uFF0C\u5355\u4F4D MB/s\uFF0C0.1 \u5373\u53EF\u8FC7\u6EE4\u6389
|
|
7827
|
+
\u7EDD\u5927\u591A\u6570\u300C\u63E1\u624B\u80FD\u8FC7\u4F46\u5E26\u5BBD\u4E0D\u53EF\u7528\u300D\u7684 IP\u3002
|
|
7828
|
+
\u7528\u7A33\u6001\u503C\u800C\u4E0D\u662F\u5CF0\u503C\uFF1A\u5355\u7A97\u53E3\u7A81\u53D1\u80FD\u628A\u5CF0\u503C\u7FFB\u500D
|
|
7829
|
+
\uFF08\u5B9E\u6D4B 2.46 vs 1.14\uFF09\uFF0C\u62FF\u5CF0\u503C\u5F53\u95E8\u69DB\u4F1A\u8BEF\u7559\u5076\u7136\u51B2\u9AD8\u7684 IP\u3002
|
|
7830
|
+
\u4E0E --no-speed\uFF08\u8DF3\u8FC7\u6D4B\u901F\uFF09\u4E92\u65A5
|
|
7807
7831
|
--cidr <a,b> \u81EA\u5B9A\u4E49\u7F51\u6BB5\uFF08\u53EF\u91CD\u590D\uFF0C\u7528\u9017\u53F7\u5206\u9694\uFF09
|
|
7808
7832
|
--ip-file <path> \u4F7F\u7528\u672C\u5730 IP \u5217\u8868\u6587\u4EF6
|
|
7809
7833
|
--ip-url <\u94FE\u63A5> \u4F7F\u7528\u8FDC\u7A0B IP \u5217\u8868\uFF08http/https\uFF0C\u4E0A\u9650 2MB\uFF0C\u4E0E --ip-file \u4E8C\u9009\u4E00\uFF09
|
|
@@ -9460,7 +9484,7 @@ async function runScanCommand(args) {
|
|
|
9460
9484
|
` ${NAME} \u672C\u5730\u6865\u63A5\u670D\u52A1\u5DF2\u542F\u52A8`,
|
|
9461
9485
|
` \u76D1\u542C\u5730\u5740\uFF1Ahttp://${host2}:${handle.port}`,
|
|
9462
9486
|
` \u7248\u672C\uFF1Av${BRIDGE_VERSION2}`,
|
|
9463
|
-
" \
|
|
9487
|
+
" \u53EF\u7528 HTTP \u63A5\u53E3\uFF1AGET /status\u3001POST /start-scan\u3001GET /events\u3001GET /results",
|
|
9464
9488
|
" \u6309 Ctrl+C \u9000\u51FA\u3002",
|
|
9465
9489
|
""
|
|
9466
9490
|
].join("\n")
|
|
@@ -9494,6 +9518,11 @@ async function runScanCommand(args) {
|
|
|
9494
9518
|
"/xhttp"
|
|
9495
9519
|
).replace(/\/+$/, "") || "/xhttp";
|
|
9496
9520
|
const noSpeed = flagBool(args, "no-speed");
|
|
9521
|
+
const minSpeedMBps = Math.max(0, flagNumber(args, "min-speed", 0));
|
|
9522
|
+
if (minSpeedMBps > 0 && noSpeed) {
|
|
9523
|
+
process.stderr.write("--min-speed \u4E0E --no-speed\uFF08\u8DF3\u8FC7\u6D4B\u901F\uFF09\u4E92\u65A5\uFF1A\u6CA1\u6709\u901F\u5EA6\u503C\u53EF\u7528\u4E8E\u7B5B\u9009\n");
|
|
9524
|
+
process.exit(1);
|
|
9525
|
+
}
|
|
9497
9526
|
const countries = normalizeCountryFilter(flagList(args, "countries"));
|
|
9498
9527
|
const panelHost = flagString(args, "panel");
|
|
9499
9528
|
const panelPassword = flagString(args, "panel-password");
|
|
@@ -9534,6 +9563,10 @@ ${NAME} v${VERSION}
|
|
|
9534
9563
|
`);
|
|
9535
9564
|
if (countries.length > 0) {
|
|
9536
9565
|
process.stdout.write(`\u56FD\u5BB6\u7B5B\u9009\uFF1A${countries.join(" / ")}\uFF08\u4E0D\u586B\u5219\u5168\u91CF\uFF09
|
|
9566
|
+
`);
|
|
9567
|
+
}
|
|
9568
|
+
if (minSpeedMBps > 0) {
|
|
9569
|
+
process.stdout.write(`\u901F\u5EA6\u8FC7\u6EE4\uFF1A\u4F4E\u4E8E ${minSpeedMBps} MB/s \u7684\u5019\u9009\u6DD8\u6C70
|
|
9537
9570
|
`);
|
|
9538
9571
|
}
|
|
9539
9572
|
}
|
|
@@ -9649,6 +9682,7 @@ ${NAME} v${VERSION}
|
|
|
9649
9682
|
wsPath,
|
|
9650
9683
|
probePath,
|
|
9651
9684
|
skipSpeed,
|
|
9685
|
+
minSpeedMBps,
|
|
9652
9686
|
verifyPayload,
|
|
9653
9687
|
concurrency: flagNumber(args, "concurrency", 300),
|
|
9654
9688
|
retries: flagNumber(args, "retries", 2),
|