cfpilot 0.9.7 → 0.10.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 +10 -10
- package/assets/dataplane.js +5 -5
- package/assets/worker.js +15 -15
- package/dist/cli.js +237 -35
- 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.10.0";
|
|
91
91
|
NAME = "cfpilot";
|
|
92
92
|
}
|
|
93
93
|
});
|
|
@@ -3671,6 +3671,103 @@ async function measureProbeThroughput(options) {
|
|
|
3671
3671
|
minBytes: 32 * 1024
|
|
3672
3672
|
});
|
|
3673
3673
|
}
|
|
3674
|
+
function buildVlessTunnelPayload(uuid, targetHost, targetPort, request) {
|
|
3675
|
+
const clean = uuid.replace(/-/g, "");
|
|
3676
|
+
if (!/^[0-9a-fA-F]{32}$/.test(clean)) return null;
|
|
3677
|
+
const hostBuf = Buffer.from(targetHost, "utf8");
|
|
3678
|
+
return Buffer.concat([
|
|
3679
|
+
Buffer.from([0]),
|
|
3680
|
+
Buffer.from(clean, "hex"),
|
|
3681
|
+
Buffer.from([0, 1, targetPort >> 8 & 255, targetPort & 255, 2, hostBuf.length]),
|
|
3682
|
+
hostBuf,
|
|
3683
|
+
Buffer.from(request, "utf8")
|
|
3684
|
+
]);
|
|
3685
|
+
}
|
|
3686
|
+
function buildTrojanTunnelPayload(password, targetHost, targetPort, request) {
|
|
3687
|
+
const digest = crypto.createHash("sha224").update(password).digest("hex");
|
|
3688
|
+
const hostBuf = Buffer.from(targetHost, "utf8");
|
|
3689
|
+
return Buffer.concat([
|
|
3690
|
+
Buffer.from(digest + "\r\n", "ascii"),
|
|
3691
|
+
Buffer.from([1, 3, hostBuf.length]),
|
|
3692
|
+
hostBuf,
|
|
3693
|
+
Buffer.from([targetPort >> 8 & 255, targetPort & 255]),
|
|
3694
|
+
Buffer.from("\r\n", "ascii"),
|
|
3695
|
+
Buffer.from(request, "utf8")
|
|
3696
|
+
]);
|
|
3697
|
+
}
|
|
3698
|
+
function tunnelUpgradeRequest(host, wsPath, key) {
|
|
3699
|
+
return ["GET " + wsPath + " HTTP/1.1", "Host: " + host, "Upgrade: websocket", "Connection: Upgrade", "Sec-WebSocket-Key: " + key, "Sec-WebSocket-Version: 13", "User-Agent: " + USER_AGENT, "", ""].join("\r\n");
|
|
3700
|
+
}
|
|
3701
|
+
function tunnelTargetRequest(targetHost) {
|
|
3702
|
+
return "GET / HTTP/1.1\r\nHost: " + targetHost + "\r\nUser-Agent: " + USER_AGENT + "\r\nConnection: close\r\n\r\n";
|
|
3703
|
+
}
|
|
3704
|
+
function verifyTunnel(options) {
|
|
3705
|
+
const { ip, port, host, wsPath, uuid, trojanPassword, targetHost = "baidu.com", targetPort = 80, timeoutMs = 8e3 } = options;
|
|
3706
|
+
const payload = uuid ? buildVlessTunnelPayload(uuid, targetHost, targetPort, tunnelTargetRequest(targetHost)) : trojanPassword ? buildTrojanTunnelPayload(trojanPassword, targetHost, targetPort, tunnelTargetRequest(targetHost)) : null;
|
|
3707
|
+
if (!payload) return Promise.resolve({ ok: false, stage: "protocol", latencyMs: 0, error: "\u7F3A\u5C11 uuid / trojanPassword" });
|
|
3708
|
+
return new Promise((resolve2) => {
|
|
3709
|
+
const started = Date.now();
|
|
3710
|
+
const key = crypto.randomBytes(16).toString("base64");
|
|
3711
|
+
let settled = false;
|
|
3712
|
+
let handshakeDone = false;
|
|
3713
|
+
let buf = Buffer.alloc(0);
|
|
3714
|
+
const finish = (r) => {
|
|
3715
|
+
if (settled) return;
|
|
3716
|
+
settled = true;
|
|
3717
|
+
clearTimeout(timer);
|
|
3718
|
+
try {
|
|
3719
|
+
socket.destroy();
|
|
3720
|
+
} catch {
|
|
3721
|
+
}
|
|
3722
|
+
resolve2({ ...r, latencyMs: Date.now() - started });
|
|
3723
|
+
};
|
|
3724
|
+
const socket = tls.connect({ host: ip, port, servername: host, rejectUnauthorized: false, ALPNProtocols: ["http/1.1"] }, () => {
|
|
3725
|
+
socket.write(tunnelUpgradeRequest(host, wsPath, key));
|
|
3726
|
+
});
|
|
3727
|
+
const timer = setTimeout(() => {
|
|
3728
|
+
finish({ ok: false, stage: handshakeDone ? "data" : "handshake", error: handshakeDone ? "\u534F\u8BAE\u5DF2\u53D1\u51FA\u4F46\u6CA1\u6709\u56DE\u5305" : "WS \u63E1\u624B\u8D85\u65F6" });
|
|
3729
|
+
}, timeoutMs);
|
|
3730
|
+
socket.on("error", (err) => finish({ ok: false, stage: handshakeDone ? "data" : "handshake", error: err.message }));
|
|
3731
|
+
socket.setTimeout(timeoutMs, () => finish({ ok: false, stage: handshakeDone ? "data" : "handshake", error: "\u8FDE\u63A5\u8D85\u65F6" }));
|
|
3732
|
+
socket.on("data", (chunk) => {
|
|
3733
|
+
buf = Buffer.concat([buf, chunk]);
|
|
3734
|
+
if (!handshakeDone) {
|
|
3735
|
+
const lineEnd = buf.indexOf("\r\n\r\n");
|
|
3736
|
+
if (lineEnd < 0) {
|
|
3737
|
+
if (buf.length > 8192) finish({ ok: false, stage: "handshake", error: "\u54CD\u5E94\u5934\u5F02\u5E38" });
|
|
3738
|
+
return;
|
|
3739
|
+
}
|
|
3740
|
+
const head = buf.slice(0, lineEnd).toString("latin1");
|
|
3741
|
+
const status2 = Number((/^HTTP\/1\.[01]\s+(\d{3})/.exec(head.split("\r\n")[0] ?? "") ?? [])[1] ?? 0);
|
|
3742
|
+
buf = buf.subarray(lineEnd + 4);
|
|
3743
|
+
if (status2 !== 101) {
|
|
3744
|
+
finish({ ok: false, stage: "handshake", error: "HTTP " + status2 });
|
|
3745
|
+
return;
|
|
3746
|
+
}
|
|
3747
|
+
handshakeDone = true;
|
|
3748
|
+
socket.write(encodeWsFrame(payload, 2));
|
|
3749
|
+
}
|
|
3750
|
+
for (; ; ) {
|
|
3751
|
+
const decoded = decodeWsFrame(buf);
|
|
3752
|
+
if (!decoded) break;
|
|
3753
|
+
buf = decoded.rest;
|
|
3754
|
+
const { opcode, payload: data } = decoded.frame;
|
|
3755
|
+
if (opcode === 8) {
|
|
3756
|
+
const code = data.length >= 2 ? data.readUInt16BE(0) : 1005;
|
|
3757
|
+
finish({ ok: false, stage: "protocol", error: "WS \u5173\u95ED\uFF08code " + code + "\uFF09" });
|
|
3758
|
+
return;
|
|
3759
|
+
}
|
|
3760
|
+
if ((opcode === 1 || opcode === 2) && data.length > 0) {
|
|
3761
|
+
const body = uuid && data.length >= 2 && data[0] === 0 && data[1] === 0 ? data.subarray(2) : data;
|
|
3762
|
+
if (body.length > 0) {
|
|
3763
|
+
finish({ ok: true, firstBytes: body.subarray(0, 16).toString("latin1") });
|
|
3764
|
+
return;
|
|
3765
|
+
}
|
|
3766
|
+
}
|
|
3767
|
+
}
|
|
3768
|
+
});
|
|
3769
|
+
});
|
|
3770
|
+
}
|
|
3674
3771
|
var WindowMeter, USER_AGENT;
|
|
3675
3772
|
var init_true_probe = __esm({
|
|
3676
3773
|
"src/scan/true-probe.ts"() {
|
|
@@ -4027,6 +4124,7 @@ async function runScan(options) {
|
|
|
4027
4124
|
});
|
|
4028
4125
|
let probeDone = 0;
|
|
4029
4126
|
let verifiedCount = 0;
|
|
4127
|
+
let pathFailures = 0;
|
|
4030
4128
|
const earlyExitTarget = hasCountryFilter ? Math.ceil(speedLimit * 1.5) : Infinity;
|
|
4031
4129
|
let matchedCount = 0;
|
|
4032
4130
|
let stoppedEarly = false;
|
|
@@ -4040,6 +4138,12 @@ async function runScan(options) {
|
|
|
4040
4138
|
retries,
|
|
4041
4139
|
() => probeFn(item.ip, options.port, options.host, probeTimeoutMs, probePath)
|
|
4042
4140
|
);
|
|
4141
|
+
let pathOk;
|
|
4142
|
+
if (result.ok && explicitWsPath && explicitWsPath !== probePath && options.verifyWsPath !== false) {
|
|
4143
|
+
const pathProbe = await probeWs101(item.ip, options.port, options.host, probeTimeoutMs, explicitWsPath);
|
|
4144
|
+
pathOk = pathProbe.ok;
|
|
4145
|
+
if (!pathOk) pathFailures++;
|
|
4146
|
+
}
|
|
4043
4147
|
probeDone++;
|
|
4044
4148
|
if (result.pongVerified) verifiedCount++;
|
|
4045
4149
|
if (hasCountryFilter && result.ok && countryFilter.includes(countryOfColo(result.colo || ""))) {
|
|
@@ -4052,7 +4156,7 @@ async function runScan(options) {
|
|
|
4052
4156
|
total: stage1.length,
|
|
4053
4157
|
message: strictProbe ? `101+PING \u6821\u9A8C ${probeDone}/${stage1.length}${result.ok ? ` \u2713 ${result.colo}` : result.pongVerified === false ? " \u2717 \u65E0\u54CD\u5E94" : ""}` : `101 \u6821\u9A8C ${probeDone}/${stage1.length}${result.ok ? ` \u2713 ${result.colo}` : ""}`
|
|
4054
4158
|
});
|
|
4055
|
-
return { ...item, probe: result };
|
|
4159
|
+
return { ...item, probe: result, pathOk };
|
|
4056
4160
|
},
|
|
4057
4161
|
() => {
|
|
4058
4162
|
if (matchedCount >= earlyExitTarget) {
|
|
@@ -4062,7 +4166,37 @@ async function runScan(options) {
|
|
|
4062
4166
|
return false;
|
|
4063
4167
|
}
|
|
4064
4168
|
);
|
|
4065
|
-
const wsOk = strictProbe ? probeResults.filter((r) => r.probe.ok && r.probe.pongVerified === true) : probeResults.filter((r) => r.probe.ok);
|
|
4169
|
+
const wsOk = (strictProbe ? probeResults.filter((r) => r.probe.ok && r.probe.pongVerified === true) : probeResults.filter((r) => r.probe.ok)).filter((r) => r.pathOk !== false);
|
|
4170
|
+
let tunnelOk = wsOk;
|
|
4171
|
+
let tunnelFailed = 0;
|
|
4172
|
+
const tunnelCredential = options.uuid || options.trojanPassword;
|
|
4173
|
+
if (tunnelCredential && options.wsPath) {
|
|
4174
|
+
const candidates2 = wsOk.slice(0, speedLimit);
|
|
4175
|
+
const verified = await pool(candidates2, 4, async (item) => {
|
|
4176
|
+
const result = await verifyTunnel({
|
|
4177
|
+
ip: item.ip,
|
|
4178
|
+
port: options.port,
|
|
4179
|
+
host: options.host,
|
|
4180
|
+
wsPath: options.wsPath,
|
|
4181
|
+
uuid: options.uuid,
|
|
4182
|
+
trojanPassword: options.trojanPassword,
|
|
4183
|
+
targetHost: options.verifyTargetHost,
|
|
4184
|
+
targetPort: options.verifyTargetPort
|
|
4185
|
+
});
|
|
4186
|
+
if (!result.ok) tunnelFailed++;
|
|
4187
|
+
report({
|
|
4188
|
+
type: "progress",
|
|
4189
|
+
stage: 2,
|
|
4190
|
+
done: candidates2.length,
|
|
4191
|
+
total: candidates2.length,
|
|
4192
|
+
message: `\u771F\u5B9E\u96A7\u9053\u6821\u9A8C ${result.ok ? "\u2713" : "\u2717 " + (result.error ?? "")}`
|
|
4193
|
+
});
|
|
4194
|
+
return { item, ok: result.ok };
|
|
4195
|
+
});
|
|
4196
|
+
const passed = new Set(verified.filter((v) => v.ok).map((v) => v.item.ip));
|
|
4197
|
+
tunnelOk = wsOk.filter((item) => passed.has(item.ip));
|
|
4198
|
+
if (tunnelOk.length === 0) tunnelOk = wsOk;
|
|
4199
|
+
}
|
|
4066
4200
|
let wsFiltered = wsOk;
|
|
4067
4201
|
let appliedCountries = [];
|
|
4068
4202
|
let countryFilterRelaxed = false;
|
|
@@ -4101,61 +4235,82 @@ async function runScan(options) {
|
|
|
4101
4235
|
const requestPath = withBytes(parsedUrl, options.speedBytes ?? 104857600);
|
|
4102
4236
|
let speedDone = 0;
|
|
4103
4237
|
speedResults = await pool(stage2, speedConcurrency, async (item) => {
|
|
4104
|
-
const
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4238
|
+
const repeat = Math.max(1, options.speedRepeat ?? 1);
|
|
4239
|
+
const samples = [];
|
|
4240
|
+
for (let r = 0; r < repeat; r++) {
|
|
4241
|
+
const one = await measureThroughput({
|
|
4242
|
+
ip: item.ip,
|
|
4243
|
+
port: options.port,
|
|
4244
|
+
sniHost: parsedUrl.host,
|
|
4245
|
+
requestHost: parsedUrl.host,
|
|
4246
|
+
path: requestPath,
|
|
4247
|
+
connections: options.speedConnections ?? 8,
|
|
4248
|
+
durationMs: options.speedDurationMs ?? 6e3,
|
|
4249
|
+
timeoutMs: options.speedTimeoutMs ?? 2e4
|
|
4250
|
+
});
|
|
4251
|
+
if (one.ok) samples.push(one.steadyMBps);
|
|
4252
|
+
}
|
|
4253
|
+
samples.sort((a, b) => a - b);
|
|
4254
|
+
const median = samples.length === 0 ? 0 : samples[Math.floor(samples.length / 2)];
|
|
4255
|
+
const jitter = samples.length < 2 ? 0 : samples[samples.length - 1] - samples[0];
|
|
4256
|
+
const result = { ok: samples.length > 0, steadyMBps: median };
|
|
4114
4257
|
speedDone++;
|
|
4115
4258
|
report({
|
|
4116
4259
|
type: "progress",
|
|
4117
4260
|
stage: 3,
|
|
4118
4261
|
done: speedDone,
|
|
4119
4262
|
total: stage2.length,
|
|
4120
|
-
message: `\u6D4B\u901F ${speedDone}/${stage2.length} [${item.probe.colo || "UNK"}] ${result.steadyMBps.toFixed(1)} MB/s`
|
|
4263
|
+
message: `\u6D4B\u901F ${speedDone}/${stage2.length} [${item.probe.colo || "UNK"}] ${result.steadyMBps.toFixed(1)} MB/s${jitter > 0 ? ` \xB1${jitter.toFixed(1)}` : ""}`
|
|
4121
4264
|
});
|
|
4122
|
-
return { ...item, speed: result.ok ? result.steadyMBps : 0 };
|
|
4265
|
+
return { ...item, speed: result.ok ? result.steadyMBps : 0, jitter };
|
|
4123
4266
|
});
|
|
4124
4267
|
} else {
|
|
4125
4268
|
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 });
|
|
4126
4269
|
let speedDone = 0;
|
|
4127
4270
|
speedResults = await pool(stage2, speedConcurrency, async (item) => {
|
|
4128
|
-
const
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4271
|
+
const repeat = Math.max(1, options.speedRepeat ?? 1);
|
|
4272
|
+
const samples = [];
|
|
4273
|
+
for (let r = 0; r < repeat; r++) {
|
|
4274
|
+
const one = await measureProbeThroughput({
|
|
4275
|
+
ip: item.ip,
|
|
4276
|
+
port: options.port,
|
|
4277
|
+
host: options.host,
|
|
4278
|
+
bytes: speedBytes,
|
|
4279
|
+
path: strictProbePath,
|
|
4280
|
+
connections: options.speedConnections ?? 8,
|
|
4281
|
+
durationMs: options.speedDurationMs ?? 6e3,
|
|
4282
|
+
timeoutMs: speedTimeoutMs,
|
|
4283
|
+
token: options.uuid
|
|
4284
|
+
});
|
|
4285
|
+
if (one.ok) samples.push(one.steadyMBps);
|
|
4286
|
+
}
|
|
4287
|
+
samples.sort((a, b) => a - b);
|
|
4288
|
+
const median = samples.length === 0 ? 0 : samples[Math.floor(samples.length / 2)];
|
|
4289
|
+
const jitter = samples.length < 2 ? 0 : samples[samples.length - 1] - samples[0];
|
|
4290
|
+
const result = { ok: samples.length > 0, steadyMBps: median };
|
|
4138
4291
|
speedDone++;
|
|
4139
4292
|
report({
|
|
4140
4293
|
type: "progress",
|
|
4141
4294
|
stage: 3,
|
|
4142
4295
|
done: speedDone,
|
|
4143
4296
|
total: stage2.length,
|
|
4144
|
-
message: `\u6D4B\u901F ${speedDone}/${stage2.length} [${item.probe.colo || "UNK"}] ${result.steadyMBps.toFixed(1)} MB/s`
|
|
4297
|
+
message: `\u6D4B\u901F ${speedDone}/${stage2.length} [${item.probe.colo || "UNK"}] ${result.steadyMBps.toFixed(1)} MB/s${jitter > 0 ? ` \xB1${jitter.toFixed(1)}` : ""}`
|
|
4145
4298
|
});
|
|
4146
4299
|
return { ...item, speed: result.ok ? result.steadyMBps : 0 };
|
|
4147
4300
|
});
|
|
4148
4301
|
}
|
|
4149
|
-
const
|
|
4302
|
+
const ranked = speedResults.filter((r) => options.skipSpeed ? true : Boolean(r.speed && r.speed > 0)).map((r) => ({
|
|
4150
4303
|
ip: r.ip,
|
|
4151
4304
|
port: options.port,
|
|
4152
4305
|
colo: r.probe.colo || "UNK",
|
|
4153
4306
|
latency: r.latency,
|
|
4154
4307
|
tlsMs: r.tls.tlsMs,
|
|
4155
|
-
speed: r.speed ? Number(r.speed.toFixed(2)) : 0
|
|
4308
|
+
speed: r.speed ? Number(r.speed.toFixed(2)) : 0,
|
|
4309
|
+
speedJitter: r.jitter ? Number(r.jitter.toFixed(2)) : 0
|
|
4156
4310
|
})).sort(
|
|
4157
4311
|
(a, b) => options.skipSpeed ? a.tlsMs - b.tlsMs || a.latency - b.latency : b.speed - a.speed || a.tlsMs - b.tlsMs || a.latency - b.latency
|
|
4158
|
-
)
|
|
4312
|
+
);
|
|
4313
|
+
const entries = pickWithDiversity(ranked, top);
|
|
4159
4314
|
for (const entry of entries) {
|
|
4160
4315
|
report({ type: "result", entry });
|
|
4161
4316
|
}
|
|
@@ -4191,6 +4346,33 @@ function formatEntries(entries) {
|
|
|
4191
4346
|
(e) => `${formatHost(e.ip)}:${e.port}#${e.colo}_${e.latency}_${e.speed}`
|
|
4192
4347
|
);
|
|
4193
4348
|
}
|
|
4349
|
+
function pickWithDiversity(ranked, top) {
|
|
4350
|
+
if (top <= 0) return [];
|
|
4351
|
+
const buckets = /* @__PURE__ */ new Map();
|
|
4352
|
+
for (const item of ranked) {
|
|
4353
|
+
const parts = item.ip.split(".");
|
|
4354
|
+
const key = parts.length >= 2 ? `${parts[0]}.${parts[1]}` : item.ip;
|
|
4355
|
+
const list = buckets.get(key);
|
|
4356
|
+
if (list) list.push(item);
|
|
4357
|
+
else buckets.set(key, [item]);
|
|
4358
|
+
}
|
|
4359
|
+
if (buckets.size <= 1) return ranked.slice(0, top);
|
|
4360
|
+
const groups = [...buckets.values()];
|
|
4361
|
+
const out = [];
|
|
4362
|
+
for (let round = 0; out.length < top; round++) {
|
|
4363
|
+
let pickedAny = false;
|
|
4364
|
+
for (const group of groups) {
|
|
4365
|
+
if (out.length >= top) break;
|
|
4366
|
+
const item = group[round];
|
|
4367
|
+
if (item) {
|
|
4368
|
+
out.push(item);
|
|
4369
|
+
pickedAny = true;
|
|
4370
|
+
}
|
|
4371
|
+
}
|
|
4372
|
+
if (!pickedAny) break;
|
|
4373
|
+
}
|
|
4374
|
+
return out;
|
|
4375
|
+
}
|
|
4194
4376
|
var init_scan = __esm({
|
|
4195
4377
|
"src/scan/scan.ts"() {
|
|
4196
4378
|
"use strict";
|
|
@@ -4446,6 +4628,7 @@ function splitByWeight(cidr) {
|
|
|
4446
4628
|
return out.sort((a, b) => a.base < b.base ? -1 : a.base > b.base ? 1 : 0);
|
|
4447
4629
|
}
|
|
4448
4630
|
function expandCidrs(cidrs, options = {}) {
|
|
4631
|
+
const neutral = options.neutral === true;
|
|
4449
4632
|
const sample = options.sample ?? 2e4;
|
|
4450
4633
|
const random = makeRandom(options.seed ?? 24301);
|
|
4451
4634
|
const parsedRaw = cidrs.map(parseCidr).filter((c2) => c2 !== null);
|
|
@@ -4471,7 +4654,8 @@ function expandCidrs(cidrs, options = {}) {
|
|
|
4471
4654
|
const familyBudget = Math.max(1, Math.round(hasOtherFamily ? sample / 2 : sample));
|
|
4472
4655
|
const effectiveSize = (c2) => {
|
|
4473
4656
|
if (c2.family !== 4) return c2.size;
|
|
4474
|
-
const
|
|
4657
|
+
const raw = cidrWeight(c2.cidr);
|
|
4658
|
+
const weight = neutral ? raw > 0 ? 1 : 0 : raw;
|
|
4475
4659
|
if (weight <= 0) return 0n;
|
|
4476
4660
|
const scaled = Number(c2.size) * weight;
|
|
4477
4661
|
return scaled >= 1 ? BigInt(Math.floor(scaled)) : 0n;
|
|
@@ -4486,7 +4670,7 @@ function expandCidrs(cidrs, options = {}) {
|
|
|
4486
4670
|
}
|
|
4487
4671
|
if (familyTotal === 0n) continue;
|
|
4488
4672
|
const minForCidr = (c2) => {
|
|
4489
|
-
if (c2.family !== 4) return minPerCidr;
|
|
4673
|
+
if (c2.family !== 4 || neutral) return minPerCidr;
|
|
4490
4674
|
const w = cidrWeight(c2.cidr);
|
|
4491
4675
|
if (w >= 1) return minPerCidr;
|
|
4492
4676
|
return Math.max(1, Math.round(minPerCidr * w));
|
|
@@ -4591,8 +4775,8 @@ var init_ip_ranges = __esm({
|
|
|
4591
4775
|
// 复测 11/12,最好的一段(旧表 0.9)
|
|
4592
4776
|
"188.114.96.0/20": 0.75,
|
|
4593
4777
|
// 复测 9/12(旧表 0.3 —— 被低估 3 倍)
|
|
4594
|
-
"172.64.0.0/13": 0.
|
|
4595
|
-
// 复测 5/12
|
|
4778
|
+
"172.64.0.0/13": 0.55,
|
|
4779
|
+
// 复测 5/12;2026-10-29 用户侧实测该段出过 9.3 MB/s(NRT),不宜压太低
|
|
4596
4780
|
"103.21.244.0/22": 0.35,
|
|
4597
4781
|
// 复测 4/12
|
|
4598
4782
|
"103.31.4.0/22": 0.3,
|
|
@@ -4833,12 +5017,13 @@ async function resolveCandidates(opts = {}) {
|
|
|
4833
5017
|
const sample = opts.sample ?? DEFAULT_CANDIDATE_SAMPLE;
|
|
4834
5018
|
const seed = opts.seed ?? randomSeed();
|
|
4835
5019
|
const family = opts.family ?? "both";
|
|
5020
|
+
const neutral = opts.neutral === true;
|
|
4836
5021
|
const customCidrs = normalizeCidrInput(opts.cidr);
|
|
4837
5022
|
if (customCidrs.length > 0) {
|
|
4838
|
-
return expandCidrs(filterByFamily(customCidrs, family), { sample, seed });
|
|
5023
|
+
return expandCidrs(filterByFamily(customCidrs, family), { sample, seed, neutral });
|
|
4839
5024
|
}
|
|
4840
5025
|
const cidrs = await loadCloudflareCidrs(family);
|
|
4841
|
-
return expandCidrs(cidrs, { sample, seed });
|
|
5026
|
+
return expandCidrs(cidrs, { sample, seed, neutral });
|
|
4842
5027
|
}
|
|
4843
5028
|
function randomSeed() {
|
|
4844
5029
|
return (Date.now() ^ Math.floor(Math.random() * 4294967296)) >>> 0;
|
|
@@ -5307,6 +5492,13 @@ scan \u9009\u9879:
|
|
|
5307
5492
|
--speed-limit <n> \u8FDB\u5165\u6D4B\u901F\u7684\u5019\u9009\u6570\uFF0C\u9ED8\u8BA4 30
|
|
5308
5493
|
--speed-bytes <n> \u6D4B\u901F\u5B57\u8282\u6570\uFF0C\u9ED8\u8BA4 5242880
|
|
5309
5494
|
--timeout <ms> \u9636\u6BB5\u4E00\u8D85\u65F6\uFF0C\u9ED8\u8BA4 1200
|
|
5495
|
+
--neutral-sampling \u4E2D\u6027\u91C7\u6837\uFF1A\u5FFD\u7565\u7F51\u6BB5\u6743\u91CD\u3001\u6309\u7F51\u6BB5\u5927\u5C0F\u7B49\u6BD4\u62BD\u53D6
|
|
5496
|
+
\uFF08\u9009\u56FD\u5BB6\u7B5B\u9009\u65F6\u4F1A\u81EA\u52A8\u542F\u7528\uFF1B\u53EA\u4FDD\u7559 TCP \u5C42\u4E0D\u53EF\u8FBE\u7684\u7F51\u6BB5\uFF09
|
|
5497
|
+
--speed-repeat <n> \u6BCF\u4E2A\u5019\u9009\u91CD\u590D\u6D4B\u901F\u6B21\u6570\uFF0C\u9ED8\u8BA4 1\uFF08>1 \u65F6\u53D6\u4E2D\u4F4D\u6570\u5E76\u663E\u793A \xB1\u6296\u52A8\uFF09
|
|
5498
|
+
--uuid <uuid> \u771F\u5B9E\u96A7\u9053\u6821\u9A8C\u7528\u7684 VLESS UUID\uFF08\u7ED9\u4E86\u624D\u4F1A\u8DD1\u9636\u6BB5\u4E8C\u70B9\u4E94\uFF09
|
|
5499
|
+
--trojan-password <pw> \u771F\u5B9E\u96A7\u9053\u6821\u9A8C\u7528\u7684 Trojan \u53E3\u4EE4\uFF08\u4E0E --uuid \u4E8C\u9009\u4E00\uFF09
|
|
5500
|
+
--verify-target <host> \u96A7\u9053\u6821\u9A8C\u8BBF\u95EE\u7684\u76EE\u6807\u57DF\u540D\uFF0C\u9ED8\u8BA4 baidu.com
|
|
5501
|
+
--no-verify-ws-path \u8DF3\u8FC7\u300C\u771F\u5B9E WS \u8DEF\u5F84 101\u300D\u8FD9\u9879\u989D\u5916\u6821\u9A8C
|
|
5310
5502
|
--seed <n> \u91C7\u6837\u968F\u673A\u79CD\u5B50\u3002\u9ED8\u8BA4\u6BCF\u6B21\u968F\u673A \u2014\u2014 \u4FDD\u8BC1\u6BCF\u6B21\u63A2\u7D22\u4E0D\u540C\u7684 IP \u5B50\u96C6
|
|
5311
5503
|
\uFF08\u5199\u6B7B\u79CD\u5B50\u4F1A\u8BA9\u6BCF\u6B21\u8DD1\u90FD\u6D4B\u540C\u4E00\u6279 IP\uFF0C\u62BD\u5230\u52A3\u8D28\u6BB5\u5C31\u6C38\u8FDC\u6D4B\u4E0D\u51FA\u597D IP\uFF09
|
|
5312
5504
|
\u663E\u5F0F\u6307\u5B9A\u5219\u56FA\u5B9A\u3001\u7ED3\u679C\u53EF\u590D\u73B0\uFF08\u6392\u67E5 / \u5BF9\u6BD4\u65F6\u7528\uFF09
|
|
@@ -5366,6 +5558,9 @@ async function resolveCandidatesFromArgs(args) {
|
|
|
5366
5558
|
return readIpFile(text);
|
|
5367
5559
|
}
|
|
5368
5560
|
return resolveCandidates({
|
|
5561
|
+
// 选国家时**自动中性采样**:采样发生在阶段一之前、那时还不知道机房,
|
|
5562
|
+
// 若某国家的 IP 集中在低权重网段,候选会被压少 → 可能「扫了几千个还是找不到 HKG/NRT」。
|
|
5563
|
+
neutral: args.flags["neutral-sampling"] !== void 0 || flagList(args, "countries").length > 0,
|
|
5369
5564
|
sample: flagNumber(args, "sample", 6556),
|
|
5370
5565
|
cidr: flagList(args, "cidr"),
|
|
5371
5566
|
// ⚠️ 不传 seed = 每次随机(默认)。只有用户显式给了 --seed 才固定,
|
|
@@ -5624,6 +5819,13 @@ ${NAME} v${VERSION}
|
|
|
5624
5819
|
// 用 3 条会系统性低估 2~4 倍。默认 8 条,贴近浏览器/客户端的真实多连接行为。
|
|
5625
5820
|
speedConnections: flagNumber(args, "speed-conns", 8),
|
|
5626
5821
|
speedDurationMs: flagNumber(args, "speed-duration", 6e3),
|
|
5822
|
+
// 真实隧道校验(可选):给了凭据才会跑
|
|
5823
|
+
uuid: flagString(args, "uuid"),
|
|
5824
|
+
trojanPassword: flagString(args, "trojan-password"),
|
|
5825
|
+
verifyTargetHost: flagString(args, "verify-target"),
|
|
5826
|
+
verifyTargetPort: flagNumber(args, "verify-target-port", 80),
|
|
5827
|
+
speedRepeat: flagNumber(args, "speed-repeat", 1),
|
|
5828
|
+
verifyWsPath: args.flags["no-verify-ws-path"] === void 0,
|
|
5627
5829
|
top,
|
|
5628
5830
|
onProgress: (event) => printProgress(event, quiet)
|
|
5629
5831
|
});
|