cfpilot 0.10.0 → 0.12.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 +10 -10
- package/assets/dataplane.js +5 -5
- package/assets/vps-socks5.sh +191 -0
- package/assets/worker.js +15 -15
- package/dist/cli.js +855 -67
- package/package.json +2 -2
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.12.1";
|
|
91
91
|
NAME = "cfpilot";
|
|
92
92
|
}
|
|
93
93
|
});
|
|
@@ -193,7 +193,7 @@ async function ask(question, options = {}) {
|
|
|
193
193
|
}
|
|
194
194
|
const suffix = fallback ? c.gray(` [${fallback}]`) : "";
|
|
195
195
|
stdout.write(`${c.cyan("?")} ${question}${suffix}${c.gray(": ")}`);
|
|
196
|
-
return await new Promise((
|
|
196
|
+
return await new Promise((resolve3) => {
|
|
197
197
|
let buf = "";
|
|
198
198
|
const wasRaw = stdin.isRaw;
|
|
199
199
|
const finish = (value) => {
|
|
@@ -201,7 +201,7 @@ async function ask(question, options = {}) {
|
|
|
201
201
|
stdin.setRawMode(wasRaw ?? false);
|
|
202
202
|
stdin.pause();
|
|
203
203
|
stdout.write("\n");
|
|
204
|
-
|
|
204
|
+
resolve3(value);
|
|
205
205
|
};
|
|
206
206
|
const onKey = (str, key) => {
|
|
207
207
|
if (key?.ctrl && key.name === "c") {
|
|
@@ -291,14 +291,14 @@ async function select(question, choices, options = {}) {
|
|
|
291
291
|
`);
|
|
292
292
|
hideCursor();
|
|
293
293
|
render(true);
|
|
294
|
-
return await new Promise((
|
|
294
|
+
return await new Promise((resolve3) => {
|
|
295
295
|
const wasRaw = stdin.isRaw;
|
|
296
296
|
const finish = (value) => {
|
|
297
297
|
stdin.removeListener("keypress", onKey);
|
|
298
298
|
stdin.setRawMode(wasRaw ?? false);
|
|
299
299
|
stdin.pause();
|
|
300
300
|
showCursor();
|
|
301
|
-
|
|
301
|
+
resolve3(value);
|
|
302
302
|
};
|
|
303
303
|
const move = (delta) => {
|
|
304
304
|
let next = cursor;
|
|
@@ -373,14 +373,14 @@ async function multiSelect(question, choices, options = {}) {
|
|
|
373
373
|
if (!first) stdout.write(`\x1B[${choices.length}A`);
|
|
374
374
|
for (let i = 0; i < choices.length; i++) {
|
|
375
375
|
const ch = choices[i];
|
|
376
|
-
const
|
|
376
|
+
const mark2 = selected.has(i) ? c.green("[x]") : c.gray("[ ]");
|
|
377
377
|
clearLine();
|
|
378
378
|
if (i === cursor) {
|
|
379
|
-
stdout.write(` ${c.cyan("\u276F")} ${
|
|
379
|
+
stdout.write(` ${c.cyan("\u276F")} ${mark2} ${c.inverse(" " + ch.label + " ")}`);
|
|
380
380
|
if (ch.hint) stdout.write(` ${c.gray(ch.hint)}`);
|
|
381
381
|
stdout.write("\n");
|
|
382
382
|
} else {
|
|
383
|
-
stdout.write(` ${
|
|
383
|
+
stdout.write(` ${mark2} ${ch.label}`);
|
|
384
384
|
if (ch.hint) stdout.write(` ${c.gray(ch.hint)}`);
|
|
385
385
|
stdout.write("\n");
|
|
386
386
|
}
|
|
@@ -390,14 +390,14 @@ async function multiSelect(question, choices, options = {}) {
|
|
|
390
390
|
`);
|
|
391
391
|
hideCursor();
|
|
392
392
|
render(true);
|
|
393
|
-
return await new Promise((
|
|
393
|
+
return await new Promise((resolve3) => {
|
|
394
394
|
const wasRaw = stdin.isRaw;
|
|
395
395
|
const finish = () => {
|
|
396
396
|
stdin.removeListener("keypress", onKey);
|
|
397
397
|
stdin.setRawMode(wasRaw ?? false);
|
|
398
398
|
stdin.pause();
|
|
399
399
|
showCursor();
|
|
400
|
-
|
|
400
|
+
resolve3([...selected].sort((a, b) => a - b).map((i) => choices[i].value));
|
|
401
401
|
};
|
|
402
402
|
const onKey = (str, key) => {
|
|
403
403
|
if (key?.ctrl && key.name === "c") {
|
|
@@ -452,7 +452,7 @@ var init_prompt = __esm({
|
|
|
452
452
|
// src/menu/store.ts
|
|
453
453
|
import { homedir } from "node:os";
|
|
454
454
|
import { join } from "node:path";
|
|
455
|
-
import { mkdirSync, readFileSync, writeFileSync, existsSync } from "node:fs";
|
|
455
|
+
import { chmodSync, mkdirSync, readFileSync, writeFileSync, existsSync } from "node:fs";
|
|
456
456
|
function configDir() {
|
|
457
457
|
const override = process.env.CFPILOT_CONFIG_DIR?.trim();
|
|
458
458
|
return override ? override : join(homedir(), ".cfpilot");
|
|
@@ -472,14 +472,28 @@ function loadConfig() {
|
|
|
472
472
|
return {};
|
|
473
473
|
}
|
|
474
474
|
}
|
|
475
|
+
function ensureConfigDir() {
|
|
476
|
+
const dir = configDir();
|
|
477
|
+
mkdirSync(dir, { recursive: true, mode: DIR_MODE });
|
|
478
|
+
try {
|
|
479
|
+
chmodSync(dir, DIR_MODE);
|
|
480
|
+
} catch {
|
|
481
|
+
}
|
|
482
|
+
return dir;
|
|
483
|
+
}
|
|
475
484
|
function saveConfig(patch) {
|
|
476
485
|
const current = loadConfig();
|
|
477
486
|
const next = { ...current, ...patch };
|
|
478
487
|
for (const k of Object.keys(next)) {
|
|
479
488
|
if (next[k] === "" || next[k] === void 0) delete next[k];
|
|
480
489
|
}
|
|
481
|
-
|
|
482
|
-
|
|
490
|
+
ensureConfigDir();
|
|
491
|
+
const file = configFile();
|
|
492
|
+
writeFileSync(file, JSON.stringify(next, null, 2) + "\n", { encoding: "utf8", mode: FILE_MODE });
|
|
493
|
+
try {
|
|
494
|
+
chmodSync(file, FILE_MODE);
|
|
495
|
+
} catch {
|
|
496
|
+
}
|
|
483
497
|
}
|
|
484
498
|
function saveToken(token, keep = {}) {
|
|
485
499
|
const trimmed = token.trim();
|
|
@@ -500,7 +514,12 @@ function saveToken(token, keep = {}) {
|
|
|
500
514
|
}
|
|
501
515
|
function clearConfig() {
|
|
502
516
|
const file = configFile();
|
|
503
|
-
if (existsSync(file))
|
|
517
|
+
if (!existsSync(file)) return;
|
|
518
|
+
writeFileSync(file, "{}\n", { encoding: "utf8", mode: FILE_MODE });
|
|
519
|
+
try {
|
|
520
|
+
chmodSync(file, FILE_MODE);
|
|
521
|
+
} catch {
|
|
522
|
+
}
|
|
504
523
|
}
|
|
505
524
|
function resolveToken(fromArgs) {
|
|
506
525
|
return (fromArgs || "").trim() || (process.env.CLOUDFLARE_API_TOKEN || "").trim() || loadConfig().token || "";
|
|
@@ -508,10 +527,12 @@ function resolveToken(fromArgs) {
|
|
|
508
527
|
function isConfigured(cfg = loadConfig()) {
|
|
509
528
|
return Boolean(cfg.token);
|
|
510
529
|
}
|
|
511
|
-
var ACCOUNT_SCOPED_FIELDS;
|
|
530
|
+
var DIR_MODE, FILE_MODE, ACCOUNT_SCOPED_FIELDS;
|
|
512
531
|
var init_store = __esm({
|
|
513
532
|
"src/menu/store.ts"() {
|
|
514
533
|
"use strict";
|
|
534
|
+
DIR_MODE = 448;
|
|
535
|
+
FILE_MODE = 384;
|
|
515
536
|
ACCOUNT_SCOPED_FIELDS = [
|
|
516
537
|
"accountId",
|
|
517
538
|
"accountName",
|
|
@@ -1567,7 +1588,8 @@ var init_github_mirrors = __esm({
|
|
|
1567
1588
|
});
|
|
1568
1589
|
|
|
1569
1590
|
// src/deploy/kernel-remote.ts
|
|
1570
|
-
import {
|
|
1591
|
+
import { createHash } from "node:crypto";
|
|
1592
|
+
import { mkdir, readFile, rename, unlink, writeFile } from "node:fs/promises";
|
|
1571
1593
|
import { homedir as homedir2 } from "node:os";
|
|
1572
1594
|
import { dirname, join as join2, resolve } from "node:path";
|
|
1573
1595
|
import { fileURLToPath } from "node:url";
|
|
@@ -1591,10 +1613,11 @@ async function fetchRemoteKernelInfo(options = {}) {
|
|
|
1591
1613
|
for (const item of sorted) {
|
|
1592
1614
|
const controlUrl = findAssetUrl(item.release.assets ?? [], CONTROL_ASSET_NAME);
|
|
1593
1615
|
const dataUrl = findAssetUrl(item.release.assets ?? [], DATA_ASSET_NAME);
|
|
1616
|
+
const checksumsUrl = findAssetUrl(item.release.assets ?? [], CHECKSUMS_ASSET_NAME);
|
|
1594
1617
|
if (!controlUrl || !dataUrl) {
|
|
1595
1618
|
continue;
|
|
1596
1619
|
}
|
|
1597
|
-
return { version: item.version, controlUrl, dataUrl };
|
|
1620
|
+
return { version: item.version, controlUrl, dataUrl, checksumsUrl };
|
|
1598
1621
|
}
|
|
1599
1622
|
return null;
|
|
1600
1623
|
}
|
|
@@ -1627,14 +1650,19 @@ async function fetchReleasesWithFallback(timeoutMs) {
|
|
|
1627
1650
|
prerelease: false,
|
|
1628
1651
|
assets: [
|
|
1629
1652
|
{ name: CONTROL_ASSET_NAME, browser_download_url: controlUrl },
|
|
1630
|
-
{ name: DATA_ASSET_NAME, browser_download_url: dataUrl }
|
|
1653
|
+
{ name: DATA_ASSET_NAME, browser_download_url: dataUrl },
|
|
1654
|
+
{
|
|
1655
|
+
name: CHECKSUMS_ASSET_NAME,
|
|
1656
|
+
browser_download_url: `${RELEASES_WEB}/latest/download/${CHECKSUMS_ASSET_NAME}`
|
|
1657
|
+
}
|
|
1631
1658
|
]
|
|
1632
1659
|
};
|
|
1633
1660
|
return [pseudo];
|
|
1634
1661
|
}
|
|
1635
1662
|
function findAssetUrl(assets, name) {
|
|
1663
|
+
const want = name.trim().toLowerCase();
|
|
1636
1664
|
for (const asset of assets) {
|
|
1637
|
-
if (asset.name.trim().toLowerCase() ===
|
|
1665
|
+
if (asset.name.trim().toLowerCase() === want) return asset.browser_download_url;
|
|
1638
1666
|
}
|
|
1639
1667
|
return "";
|
|
1640
1668
|
}
|
|
@@ -1650,10 +1678,11 @@ function isGitHubRelease(value) {
|
|
|
1650
1678
|
if (item.assets !== void 0 && !Array.isArray(item.assets)) return false;
|
|
1651
1679
|
return true;
|
|
1652
1680
|
}
|
|
1653
|
-
async function downloadAsset(url, timeoutMs) {
|
|
1681
|
+
async function downloadAsset(url, timeoutMs, options = {}) {
|
|
1654
1682
|
if (!url.trim()) throw new Error("\u4E0B\u8F7D\u5730\u5740\u4E3A\u7A7A");
|
|
1683
|
+
const sources = options.allowMirrors === false ? [{ name: "GitHub", url }] : downloadSources(url);
|
|
1655
1684
|
const errors = [];
|
|
1656
|
-
for (const source of
|
|
1685
|
+
for (const source of sources) {
|
|
1657
1686
|
try {
|
|
1658
1687
|
const response = await fetch(source.url, {
|
|
1659
1688
|
headers: { "User-Agent": "CFPilot-CLI" },
|
|
@@ -1710,6 +1739,47 @@ async function readBodyWithLimit(response) {
|
|
|
1710
1739
|
out += decoder.decode();
|
|
1711
1740
|
return out;
|
|
1712
1741
|
}
|
|
1742
|
+
function sha256Hex(content) {
|
|
1743
|
+
return createHash("sha256").update(content, "utf8").digest("hex");
|
|
1744
|
+
}
|
|
1745
|
+
function parseChecksums(text) {
|
|
1746
|
+
const out = /* @__PURE__ */ new Map();
|
|
1747
|
+
for (const raw of text.split("\n")) {
|
|
1748
|
+
const line = raw.trim();
|
|
1749
|
+
if (!line || line.startsWith("#")) continue;
|
|
1750
|
+
const match = /^([0-9a-fA-F]{64})\s+\*?(.+)$/.exec(line);
|
|
1751
|
+
if (!match) continue;
|
|
1752
|
+
out.set(match[2].trim().toLowerCase(), match[1].toLowerCase());
|
|
1753
|
+
}
|
|
1754
|
+
return out;
|
|
1755
|
+
}
|
|
1756
|
+
async function downloadChecksums(info, timeoutMs) {
|
|
1757
|
+
if (!info.checksumsUrl.trim()) {
|
|
1758
|
+
throw new Error(
|
|
1759
|
+
`Release ${info.version} \u672A\u53D1\u5E03 ${CHECKSUMS_ASSET_NAME}\uFF0C\u65E0\u6CD5\u6821\u9A8C\u5185\u6838\u5B8C\u6574\u6027`
|
|
1760
|
+
);
|
|
1761
|
+
}
|
|
1762
|
+
const text = await downloadAsset(info.checksumsUrl, timeoutMs, { allowMirrors: false });
|
|
1763
|
+
const map = parseChecksums(text);
|
|
1764
|
+
for (const name of [CONTROL_ASSET_NAME, DATA_ASSET_NAME]) {
|
|
1765
|
+
if (!map.has(name.toLowerCase())) {
|
|
1766
|
+
throw new Error(`\u5185\u6838\u6821\u9A8C\u6E05\u5355\u7F3A\u5C11 ${name} \u7684\u6458\u8981`);
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
return { text, map };
|
|
1770
|
+
}
|
|
1771
|
+
function verifyAsset(shortName, content, map) {
|
|
1772
|
+
const assetName = ASSET_BY_SHORT_NAME[shortName];
|
|
1773
|
+
if (!assetName) throw new Error(`\u672A\u77E5\u5185\u6838\u4EA7\u7269\uFF1A${shortName}`);
|
|
1774
|
+
const expected = map.get(assetName.toLowerCase());
|
|
1775
|
+
if (!expected) throw new Error(`\u6821\u9A8C\u6E05\u5355\u7F3A\u5C11 ${assetName} \u7684\u6458\u8981`);
|
|
1776
|
+
const actual = sha256Hex(content);
|
|
1777
|
+
if (actual !== expected) {
|
|
1778
|
+
throw new Error(
|
|
1779
|
+
`\u5185\u6838\u4EA7\u7269 ${assetName} \u6458\u8981\u4E0D\u5339\u914D\uFF08\u671F\u671B ${expected.slice(0, 12)}\u2026\uFF0C\u5B9E\u9645 ${actual.slice(0, 12)}\u2026\uFF09\u2014\u2014 \u5DF2\u62D2\u7EDD\u4F7F\u7528`
|
|
1780
|
+
);
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1713
1783
|
function cacheRoot() {
|
|
1714
1784
|
const override = process.env[CACHE_DIR_ENV]?.trim();
|
|
1715
1785
|
if (override) return override;
|
|
@@ -1783,7 +1853,7 @@ async function loadKernelBundle(currentVersion, options = {}) {
|
|
|
1783
1853
|
control: bundle.control,
|
|
1784
1854
|
data: bundle.data,
|
|
1785
1855
|
version: remote.version,
|
|
1786
|
-
source: `\u8FDC\u7A0B ${remote.version}`
|
|
1856
|
+
source: `\u8FDC\u7A0B ${remote.version}\uFF08\u5DF2\u6821\u9A8C\uFF09`
|
|
1787
1857
|
};
|
|
1788
1858
|
} catch (err) {
|
|
1789
1859
|
log(
|
|
@@ -1804,20 +1874,46 @@ async function fetchRemoteKernel(info, timeoutMs) {
|
|
|
1804
1874
|
const dir = cacheDir(info.version);
|
|
1805
1875
|
const controlPath = join2(dir, "control.js");
|
|
1806
1876
|
const dataPath = join2(dir, "dataplane.js");
|
|
1807
|
-
const
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1877
|
+
const sumsPath = join2(dir, "SHA256SUMS");
|
|
1878
|
+
let sumsText = await readCached(sumsPath);
|
|
1879
|
+
let sums = sumsText ? parseChecksums(sumsText) : null;
|
|
1880
|
+
const sumsComplete = sums !== null && sums.has(CONTROL_ASSET_NAME.toLowerCase()) && sums.has(DATA_ASSET_NAME.toLowerCase());
|
|
1881
|
+
if (!sums || !sumsComplete) {
|
|
1882
|
+
const fetched = await downloadChecksums(info, timeoutMs);
|
|
1883
|
+
sumsText = fetched.text;
|
|
1884
|
+
sums = fetched.map;
|
|
1885
|
+
}
|
|
1886
|
+
let control = await readCached(controlPath);
|
|
1887
|
+
let data = await readCached(dataPath);
|
|
1888
|
+
if (control) {
|
|
1889
|
+
try {
|
|
1890
|
+
verifyAsset("control.js", control, sums);
|
|
1891
|
+
} catch {
|
|
1892
|
+
control = null;
|
|
1893
|
+
await unlink(controlPath).catch(() => void 0);
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
if (data) {
|
|
1897
|
+
try {
|
|
1898
|
+
verifyAsset("dataplane.js", data, sums);
|
|
1899
|
+
} catch {
|
|
1900
|
+
data = null;
|
|
1901
|
+
await unlink(dataPath).catch(() => void 0);
|
|
1902
|
+
}
|
|
1811
1903
|
}
|
|
1812
|
-
|
|
1813
|
-
|
|
1904
|
+
if (control && data) return { control, data };
|
|
1905
|
+
control ??= await downloadAsset(info.controlUrl, timeoutMs);
|
|
1906
|
+
verifyAsset("control.js", control, sums);
|
|
1907
|
+
data ??= await downloadAsset(info.dataUrl, timeoutMs);
|
|
1908
|
+
verifyAsset("dataplane.js", data, sums);
|
|
1814
1909
|
if (!control.trim()) throw new Error("\u4E0B\u8F7D\u5230\u7684\u63A7\u5236\u9762\u4EA7\u7269\u4E3A\u7A7A");
|
|
1815
1910
|
if (!data.trim()) throw new Error("\u4E0B\u8F7D\u5230\u7684\u6570\u636E\u9762\u4EA7\u7269\u4E3A\u7A7A");
|
|
1911
|
+
await writeCached(sumsPath, sumsText).catch(() => void 0);
|
|
1816
1912
|
await writeCached(controlPath, control).catch(() => void 0);
|
|
1817
1913
|
await writeCached(dataPath, data).catch(() => void 0);
|
|
1818
1914
|
return { control, data };
|
|
1819
1915
|
}
|
|
1820
|
-
var CONTROL_ASSET_NAME, DATA_ASSET_NAME, REPO, RELEASES_API2, DEFAULT_TIMEOUT_MS, MAX_ASSET_BYTES, CACHE_DIR_ENV, LOCAL_DIR_ENV, REMOTE_OFF_ENV, BUILD_RE, BUILD_NUMERIC_RE;
|
|
1916
|
+
var CONTROL_ASSET_NAME, DATA_ASSET_NAME, CHECKSUMS_ASSET_NAME, REPO, RELEASES_API2, DEFAULT_TIMEOUT_MS, MAX_ASSET_BYTES, CACHE_DIR_ENV, LOCAL_DIR_ENV, REMOTE_OFF_ENV, BUILD_RE, BUILD_NUMERIC_RE, ASSET_BY_SHORT_NAME;
|
|
1821
1917
|
var init_kernel_remote = __esm({
|
|
1822
1918
|
"src/deploy/kernel-remote.ts"() {
|
|
1823
1919
|
"use strict";
|
|
@@ -1825,6 +1921,7 @@ var init_kernel_remote = __esm({
|
|
|
1825
1921
|
init_github_mirrors();
|
|
1826
1922
|
CONTROL_ASSET_NAME = "cfpilot-kernel-control.js";
|
|
1827
1923
|
DATA_ASSET_NAME = "cfpilot-kernel-dataplane.js";
|
|
1924
|
+
CHECKSUMS_ASSET_NAME = "cfpilot-kernel-SHA256SUMS";
|
|
1828
1925
|
REPO = "xmwengxing/CFPilot";
|
|
1829
1926
|
RELEASES_API2 = process.env.CFPILOT_KERNEL_API_BASE ?? `https://api.github.com/repos/${REPO}/releases`;
|
|
1830
1927
|
DEFAULT_TIMEOUT_MS = 2e4;
|
|
@@ -1834,6 +1931,10 @@ var init_kernel_remote = __esm({
|
|
|
1834
1931
|
REMOTE_OFF_ENV = "CFPILOT_KERNEL_REMOTE";
|
|
1835
1932
|
BUILD_RE = /["']([0-9a-f]{7,10}-(?:[0-9a-f]{4,16}|[0-9]{12}))["']/;
|
|
1836
1933
|
BUILD_NUMERIC_RE = /["'](\d{10,14})["']/;
|
|
1934
|
+
ASSET_BY_SHORT_NAME = {
|
|
1935
|
+
"control.js": CONTROL_ASSET_NAME,
|
|
1936
|
+
"dataplane.js": DATA_ASSET_NAME
|
|
1937
|
+
};
|
|
1837
1938
|
}
|
|
1838
1939
|
});
|
|
1839
1940
|
|
|
@@ -3160,6 +3261,11 @@ var init_status = __esm({
|
|
|
3160
3261
|
});
|
|
3161
3262
|
|
|
3162
3263
|
// src/scan/countries.ts
|
|
3264
|
+
function isRegionGroup(code) {
|
|
3265
|
+
const key = String(code ?? "").trim().toUpperCase();
|
|
3266
|
+
if (!Object.prototype.hasOwnProperty.call(REGION_GROUPS, key)) return false;
|
|
3267
|
+
return true;
|
|
3268
|
+
}
|
|
3163
3269
|
function countryOfColo(colo) {
|
|
3164
3270
|
return coloToCountry.get(colo.toUpperCase()) ?? "";
|
|
3165
3271
|
}
|
|
@@ -3169,14 +3275,29 @@ function isKnownCountry(code) {
|
|
|
3169
3275
|
function normalizeCountryFilter(input) {
|
|
3170
3276
|
if (!Array.isArray(input)) return [];
|
|
3171
3277
|
const out = [];
|
|
3278
|
+
const push = (code) => {
|
|
3279
|
+
if (code && !out.includes(code)) out.push(code);
|
|
3280
|
+
};
|
|
3172
3281
|
for (const raw of input) {
|
|
3173
3282
|
const code = String(raw ?? "").trim().toUpperCase();
|
|
3174
|
-
if (!code
|
|
3175
|
-
if (
|
|
3283
|
+
if (!code) continue;
|
|
3284
|
+
if (isRegionGroup(code)) {
|
|
3285
|
+
for (const member of REGION_GROUPS[code] ?? []) push(String(member).toUpperCase());
|
|
3286
|
+
continue;
|
|
3287
|
+
}
|
|
3288
|
+
if (isKnownCountry(code)) {
|
|
3289
|
+
push(code);
|
|
3290
|
+
continue;
|
|
3291
|
+
}
|
|
3292
|
+
const country = countryOfColo(code);
|
|
3293
|
+
if (country) push(country);
|
|
3176
3294
|
}
|
|
3177
3295
|
return out;
|
|
3178
3296
|
}
|
|
3179
|
-
|
|
3297
|
+
function coloCity(colo) {
|
|
3298
|
+
return COLO_CITIES[colo.toUpperCase()] ?? "";
|
|
3299
|
+
}
|
|
3300
|
+
var COUNTRY_COLOS, REGION_GROUPS, REGION_GROUP_NAMES, coloToCountry, SUPPORTED_COUNTRIES, COLO_CITIES;
|
|
3180
3301
|
var init_countries = __esm({
|
|
3181
3302
|
"src/scan/countries.ts"() {
|
|
3182
3303
|
"use strict";
|
|
@@ -3216,11 +3337,88 @@ var init_countries = __esm({
|
|
|
3216
3337
|
CL: ["SCL"],
|
|
3217
3338
|
MX: ["MEX"]
|
|
3218
3339
|
};
|
|
3340
|
+
REGION_GROUPS = {
|
|
3341
|
+
ASIA: ["HK", "TW", "JP", "KR", "SG", "MY", "TH", "VN", "ID", "PH", "IN", "AE", "IL"],
|
|
3342
|
+
US: ["US"]
|
|
3343
|
+
};
|
|
3344
|
+
REGION_GROUP_NAMES = {
|
|
3345
|
+
ASIA: "\u4E9A\u6D32\u7EC4",
|
|
3346
|
+
US: "\u7F8E\u56FD\u7EC4"
|
|
3347
|
+
};
|
|
3219
3348
|
coloToCountry = /* @__PURE__ */ new Map();
|
|
3220
3349
|
for (const [country, colos] of Object.entries(COUNTRY_COLOS)) {
|
|
3221
3350
|
for (const colo of colos) coloToCountry.set(colo, country);
|
|
3222
3351
|
}
|
|
3223
3352
|
SUPPORTED_COUNTRIES = Object.keys(COUNTRY_COLOS);
|
|
3353
|
+
COLO_CITIES = {
|
|
3354
|
+
HKG: "\u9999\u6E2F",
|
|
3355
|
+
TPE: "\u53F0\u5317",
|
|
3356
|
+
KHH: "\u9AD8\u96C4",
|
|
3357
|
+
NRT: "\u4E1C\u4EAC",
|
|
3358
|
+
KIX: "\u5927\u962A",
|
|
3359
|
+
CTS: "\u672D\u5E4C",
|
|
3360
|
+
FUK: "\u798F\u5188",
|
|
3361
|
+
ICN: "\u9996\u5C14",
|
|
3362
|
+
PUS: "\u91DC\u5C71",
|
|
3363
|
+
SIN: "\u65B0\u52A0\u5761",
|
|
3364
|
+
KUL: "\u5409\u9686\u5761",
|
|
3365
|
+
BKK: "\u66FC\u8C37",
|
|
3366
|
+
SGN: "\u80E1\u5FD7\u660E\u5E02",
|
|
3367
|
+
HAN: "\u6CB3\u5185",
|
|
3368
|
+
CGK: "\u96C5\u52A0\u8FBE",
|
|
3369
|
+
DPS: "\u767B\u5DF4\u8428",
|
|
3370
|
+
MNL: "\u9A6C\u5C3C\u62C9",
|
|
3371
|
+
BOM: "\u5B5F\u4E70",
|
|
3372
|
+
MAA: "\u91D1\u5948",
|
|
3373
|
+
DEL: "\u65B0\u5FB7\u91CC",
|
|
3374
|
+
SYD: "\u6089\u5C3C",
|
|
3375
|
+
MEL: "\u58A8\u5C14\u672C",
|
|
3376
|
+
BNE: "\u5E03\u91CC\u65AF\u73ED",
|
|
3377
|
+
PER: "\u73C0\u65AF",
|
|
3378
|
+
AKL: "\u5965\u514B\u5170",
|
|
3379
|
+
LAX: "\u6D1B\u6749\u77F6",
|
|
3380
|
+
SJC: "\u5723\u4F55\u585E",
|
|
3381
|
+
SEA: "\u897F\u96C5\u56FE",
|
|
3382
|
+
ORD: "\u829D\u52A0\u54E5",
|
|
3383
|
+
DFW: "\u8FBE\u62C9\u65AF",
|
|
3384
|
+
IAD: "\u534E\u76DB\u987F",
|
|
3385
|
+
EWR: "\u7EBD\u74E6\u514B",
|
|
3386
|
+
ATL: "\u4E9A\u7279\u5170\u5927",
|
|
3387
|
+
MIA: "\u8FC8\u963F\u5BC6",
|
|
3388
|
+
DEN: "\u4E39\u4F5B",
|
|
3389
|
+
PHX: "\u51E4\u51F0\u57CE",
|
|
3390
|
+
BOS: "\u6CE2\u58EB\u987F",
|
|
3391
|
+
YYZ: "\u591A\u4F26\u591A",
|
|
3392
|
+
YVR: "\u6E29\u54E5\u534E",
|
|
3393
|
+
YYC: "\u5361\u5C14\u52A0\u91CC",
|
|
3394
|
+
LHR: "\u4F26\u6566",
|
|
3395
|
+
MAN: "\u66FC\u5F7B\u65AF\u7279",
|
|
3396
|
+
FRA: "\u6CD5\u5170\u514B\u798F",
|
|
3397
|
+
MUC: "\u6155\u5C3C\u9ED1",
|
|
3398
|
+
BER: "\u67CF\u6797",
|
|
3399
|
+
CDG: "\u5DF4\u9ECE",
|
|
3400
|
+
MRS: "\u9A6C\u8D5B",
|
|
3401
|
+
AMS: "\u963F\u59C6\u65AF\u7279\u4E39",
|
|
3402
|
+
MXP: "\u7C73\u5170",
|
|
3403
|
+
FCO: "\u7F57\u9A6C",
|
|
3404
|
+
MAD: "\u9A6C\u5FB7\u91CC",
|
|
3405
|
+
BCN: "\u5DF4\u585E\u7F57\u90A3",
|
|
3406
|
+
ARN: "\u65AF\u5FB7\u54E5\u5C14\u6469",
|
|
3407
|
+
ZRH: "\u82CF\u9ECE\u4E16",
|
|
3408
|
+
VIE: "\u7EF4\u4E5F\u7EB3",
|
|
3409
|
+
WAW: "\u534E\u6C99",
|
|
3410
|
+
DME: "\u83AB\u65AF\u79D1",
|
|
3411
|
+
SVO: "\u83AB\u65AF\u79D1",
|
|
3412
|
+
IST: "\u4F0A\u65AF\u5766\u5E03\u5C14",
|
|
3413
|
+
DXB: "\u8FEA\u62DC",
|
|
3414
|
+
TLV: "\u7279\u62C9\u7EF4\u592B",
|
|
3415
|
+
JNB: "\u7EA6\u7FF0\u5185\u65AF\u5821",
|
|
3416
|
+
GRU: "\u5723\u4FDD\u7F57",
|
|
3417
|
+
GIG: "\u91CC\u7EA6\u70ED\u5185\u5362",
|
|
3418
|
+
EZE: "\u5E03\u5B9C\u8BFA\u65AF\u827E\u5229\u65AF",
|
|
3419
|
+
SCL: "\u5723\u5730\u4E9A\u54E5",
|
|
3420
|
+
MEX: "\u58A8\u897F\u54E5\u57CE"
|
|
3421
|
+
};
|
|
3224
3422
|
}
|
|
3225
3423
|
});
|
|
3226
3424
|
|
|
@@ -3232,7 +3430,7 @@ function extractColo(text) {
|
|
|
3232
3430
|
return match ? match[1].toUpperCase() : "";
|
|
3233
3431
|
}
|
|
3234
3432
|
function probeWs101(ip, port, host, timeoutMs = 3e3, path = "/__edge_probe") {
|
|
3235
|
-
return new Promise((
|
|
3433
|
+
return new Promise((resolve3) => {
|
|
3236
3434
|
const started = Date.now();
|
|
3237
3435
|
const key = crypto.randomBytes(16).toString("base64");
|
|
3238
3436
|
let settled = false;
|
|
@@ -3245,7 +3443,7 @@ function probeWs101(ip, port, host, timeoutMs = 3e3, path = "/__edge_probe") {
|
|
|
3245
3443
|
socket.destroy();
|
|
3246
3444
|
} catch {
|
|
3247
3445
|
}
|
|
3248
|
-
|
|
3446
|
+
resolve3({ ...result, latencyMs: Date.now() - started });
|
|
3249
3447
|
};
|
|
3250
3448
|
const request = [
|
|
3251
3449
|
`GET ${path} HTTP/1.1`,
|
|
@@ -3348,7 +3546,7 @@ function decodeWsFrame(buf) {
|
|
|
3348
3546
|
return { frame, rest };
|
|
3349
3547
|
}
|
|
3350
3548
|
function probeWsPing(ip, port, host, timeoutMs = 5e3, path = "/__edge_probe") {
|
|
3351
|
-
return new Promise((
|
|
3549
|
+
return new Promise((resolve3) => {
|
|
3352
3550
|
const started = Date.now();
|
|
3353
3551
|
const key = crypto.randomBytes(16).toString("base64");
|
|
3354
3552
|
let settled = false;
|
|
@@ -3363,7 +3561,7 @@ function probeWsPing(ip, port, host, timeoutMs = 5e3, path = "/__edge_probe") {
|
|
|
3363
3561
|
socket.destroy();
|
|
3364
3562
|
} catch {
|
|
3365
3563
|
}
|
|
3366
|
-
|
|
3564
|
+
resolve3({ ...result, latencyMs: Date.now() - started });
|
|
3367
3565
|
};
|
|
3368
3566
|
const request = [
|
|
3369
3567
|
`GET ${path} HTTP/1.1`,
|
|
@@ -3474,7 +3672,7 @@ function probeWsPing(ip, port, host, timeoutMs = 5e3, path = "/__edge_probe") {
|
|
|
3474
3672
|
});
|
|
3475
3673
|
}
|
|
3476
3674
|
function probeTlsHandshake(ip, port, host, timeoutMs = 4e3) {
|
|
3477
|
-
return new Promise((
|
|
3675
|
+
return new Promise((resolve3) => {
|
|
3478
3676
|
const started = Date.now();
|
|
3479
3677
|
let settled = false;
|
|
3480
3678
|
const finish = (result) => {
|
|
@@ -3485,7 +3683,7 @@ function probeTlsHandshake(ip, port, host, timeoutMs = 4e3) {
|
|
|
3485
3683
|
socket.destroy();
|
|
3486
3684
|
} catch {
|
|
3487
3685
|
}
|
|
3488
|
-
|
|
3686
|
+
resolve3({ ip, tlsMs: result.tlsMs ?? Date.now() - started, ...result });
|
|
3489
3687
|
};
|
|
3490
3688
|
const socket = tls.connect(
|
|
3491
3689
|
{
|
|
@@ -3525,7 +3723,7 @@ function measureThroughput(options) {
|
|
|
3525
3723
|
minBytes = 32 * 1024
|
|
3526
3724
|
} = options;
|
|
3527
3725
|
const connCount = Math.max(1, Math.min(8, connections));
|
|
3528
|
-
return new Promise((
|
|
3726
|
+
return new Promise((resolve3) => {
|
|
3529
3727
|
const started = Date.now();
|
|
3530
3728
|
let settled = false;
|
|
3531
3729
|
const meter = new WindowMeter({ startedAt: started, warmupMs, windowMs });
|
|
@@ -3555,7 +3753,7 @@ function measureThroughput(options) {
|
|
|
3555
3753
|
else if (totalBytes === 0) error = lastError || "\u672A\u6536\u5230\u6570\u636E";
|
|
3556
3754
|
else error = lastError || `\u8F7D\u8377\u4E0D\u8DB3\uFF08${totalBytes}/${minBytes} \u5B57\u8282\uFF09`;
|
|
3557
3755
|
}
|
|
3558
|
-
|
|
3756
|
+
resolve3({
|
|
3559
3757
|
ok,
|
|
3560
3758
|
bytes: totalBytes,
|
|
3561
3759
|
ms: now - started,
|
|
@@ -3705,7 +3903,7 @@ function verifyTunnel(options) {
|
|
|
3705
3903
|
const { ip, port, host, wsPath, uuid, trojanPassword, targetHost = "baidu.com", targetPort = 80, timeoutMs = 8e3 } = options;
|
|
3706
3904
|
const payload = uuid ? buildVlessTunnelPayload(uuid, targetHost, targetPort, tunnelTargetRequest(targetHost)) : trojanPassword ? buildTrojanTunnelPayload(trojanPassword, targetHost, targetPort, tunnelTargetRequest(targetHost)) : null;
|
|
3707
3905
|
if (!payload) return Promise.resolve({ ok: false, stage: "protocol", latencyMs: 0, error: "\u7F3A\u5C11 uuid / trojanPassword" });
|
|
3708
|
-
return new Promise((
|
|
3906
|
+
return new Promise((resolve3) => {
|
|
3709
3907
|
const started = Date.now();
|
|
3710
3908
|
const key = crypto.randomBytes(16).toString("base64");
|
|
3711
3909
|
let settled = false;
|
|
@@ -3719,7 +3917,7 @@ function verifyTunnel(options) {
|
|
|
3719
3917
|
socket.destroy();
|
|
3720
3918
|
} catch {
|
|
3721
3919
|
}
|
|
3722
|
-
|
|
3920
|
+
resolve3({ ...r, latencyMs: Date.now() - started });
|
|
3723
3921
|
};
|
|
3724
3922
|
const socket = tls.connect({ host: ip, port, servername: host, rejectUnauthorized: false, ALPNProtocols: ["http/1.1"] }, () => {
|
|
3725
3923
|
socket.write(tunnelUpgradeRequest(host, wsPath, key));
|
|
@@ -3889,7 +4087,7 @@ function schemeForPort(port) {
|
|
|
3889
4087
|
return port === 443 || port === 2053 || port === 2083 || port === 2087 || port === 2096 || port === 8443 ? "https" : "http";
|
|
3890
4088
|
}
|
|
3891
4089
|
function checkSpeedUrlAvailable(parsed, timeoutMs = 6e3) {
|
|
3892
|
-
return new Promise((
|
|
4090
|
+
return new Promise((resolve3) => {
|
|
3893
4091
|
let settled = false;
|
|
3894
4092
|
let received = "";
|
|
3895
4093
|
const finish = (available, status2, error) => {
|
|
@@ -3900,7 +4098,7 @@ function checkSpeedUrlAvailable(parsed, timeoutMs = 6e3) {
|
|
|
3900
4098
|
socket.destroy();
|
|
3901
4099
|
} catch {
|
|
3902
4100
|
}
|
|
3903
|
-
|
|
4101
|
+
resolve3({ available, status: status2, error });
|
|
3904
4102
|
};
|
|
3905
4103
|
const path = parsed.path.includes("bytes=") ? parsed.path.replace(/bytes=\d+/, "bytes=1024") : parsed.path;
|
|
3906
4104
|
const request = [
|
|
@@ -3977,10 +4175,121 @@ var init_speed_url = __esm({
|
|
|
3977
4175
|
}
|
|
3978
4176
|
});
|
|
3979
4177
|
|
|
4178
|
+
// src/scan/unlock.ts
|
|
4179
|
+
import * as tls3 from "node:tls";
|
|
4180
|
+
function probeUnlock(options) {
|
|
4181
|
+
const { ip, port = 443, host, token, timeoutMs = 12e3 } = options;
|
|
4182
|
+
return new Promise((resolve3) => {
|
|
4183
|
+
let settled = false;
|
|
4184
|
+
let raw = Buffer.alloc(0);
|
|
4185
|
+
const finish = (result) => {
|
|
4186
|
+
if (settled) return;
|
|
4187
|
+
settled = true;
|
|
4188
|
+
try {
|
|
4189
|
+
socket.destroy();
|
|
4190
|
+
} catch {
|
|
4191
|
+
}
|
|
4192
|
+
resolve3(result);
|
|
4193
|
+
};
|
|
4194
|
+
const socket = tls3.connect(
|
|
4195
|
+
{
|
|
4196
|
+
host: ip,
|
|
4197
|
+
port,
|
|
4198
|
+
servername: host,
|
|
4199
|
+
// 证书是给域名签的,我们连的是 IP;这里只验证「能不能通」,不校验证书链
|
|
4200
|
+
rejectUnauthorized: false,
|
|
4201
|
+
ALPNProtocols: ["http/1.1"]
|
|
4202
|
+
},
|
|
4203
|
+
() => {
|
|
4204
|
+
socket.write(
|
|
4205
|
+
[
|
|
4206
|
+
"GET /__unlock_probe HTTP/1.1",
|
|
4207
|
+
`Host: ${host}`,
|
|
4208
|
+
`x-cfpilot-token: ${token}`,
|
|
4209
|
+
"Accept: application/json",
|
|
4210
|
+
"Connection: close",
|
|
4211
|
+
"",
|
|
4212
|
+
""
|
|
4213
|
+
].join("\r\n")
|
|
4214
|
+
);
|
|
4215
|
+
}
|
|
4216
|
+
);
|
|
4217
|
+
socket.setTimeout(timeoutMs, () => finish({ ok: false, colo: "", region: "", targets: [], error: "\u8D85\u65F6" }));
|
|
4218
|
+
socket.on("error", (err) => finish({ ok: false, colo: "", region: "", targets: [], error: err.message }));
|
|
4219
|
+
socket.on("data", (chunk) => {
|
|
4220
|
+
raw = raw.length === 0 ? chunk : Buffer.concat([raw, chunk]);
|
|
4221
|
+
const idx = raw.indexOf("\r\n\r\n");
|
|
4222
|
+
if (idx < 0) {
|
|
4223
|
+
if (raw.length > 16384) finish({ ok: false, colo: "", region: "", targets: [], error: "\u54CD\u5E94\u5934\u5F02\u5E38" });
|
|
4224
|
+
return;
|
|
4225
|
+
}
|
|
4226
|
+
const head = raw.subarray(0, idx).toString("latin1");
|
|
4227
|
+
const status2 = /^HTTP\/1\.[01]\s+(\d{3})/.exec(head)?.[1];
|
|
4228
|
+
const body = raw.subarray(idx + 4).toString("utf8");
|
|
4229
|
+
if (status2 !== "200") {
|
|
4230
|
+
finish({
|
|
4231
|
+
ok: false,
|
|
4232
|
+
colo: "",
|
|
4233
|
+
region: "",
|
|
4234
|
+
targets: [],
|
|
4235
|
+
error: status2 === "404" ? "\u7AEF\u70B9\u672A\u5F00\u542F\uFF08\u9762\u677F\u300C\u51FA\u7AD9\u4E0E\u9AD8\u7EA7\u300D\u91CC\u6253\u5F00\u300C\u51FA\u53E3\u4F53\u68C0\u300D\uFF09" : status2 === "403" ? "\u4EE4\u724C\u65E0\u6548\uFF08\u9700\u4F20\u5B8C\u6574 UUID\uFF09" : `HTTP ${status2 ?? "?"}`
|
|
4236
|
+
});
|
|
4237
|
+
return;
|
|
4238
|
+
}
|
|
4239
|
+
try {
|
|
4240
|
+
const parsed = JSON.parse(body);
|
|
4241
|
+
finish({
|
|
4242
|
+
ok: true,
|
|
4243
|
+
colo: parsed.colo ?? "",
|
|
4244
|
+
region: parsed.region ?? "",
|
|
4245
|
+
targets: Array.isArray(parsed.targets) ? parsed.targets : []
|
|
4246
|
+
});
|
|
4247
|
+
} catch {
|
|
4248
|
+
finish({ ok: false, colo: "", region: "", targets: [], error: "\u54CD\u5E94\u4E0D\u662F\u5408\u6CD5 JSON" });
|
|
4249
|
+
}
|
|
4250
|
+
});
|
|
4251
|
+
socket.on("end", () => {
|
|
4252
|
+
if (!settled) finish({ ok: false, colo: "", region: "", targets: [], error: "\u8FDE\u63A5\u63D0\u524D\u7ED3\u675F" });
|
|
4253
|
+
});
|
|
4254
|
+
});
|
|
4255
|
+
}
|
|
4256
|
+
function describeUnlock(result) {
|
|
4257
|
+
if (!result.ok) return `\u4F53\u68C0\u5931\u8D25\uFF1A${result.error ?? "\u672A\u77E5\u539F\u56E0"}`;
|
|
4258
|
+
const parts = result.targets.map((t) => `${t.id}:${t.verdict}`);
|
|
4259
|
+
return `${result.colo || "UNK"} ${parts.join(" ")}`;
|
|
4260
|
+
}
|
|
4261
|
+
var init_unlock = __esm({
|
|
4262
|
+
"src/scan/unlock.ts"() {
|
|
4263
|
+
"use strict";
|
|
4264
|
+
}
|
|
4265
|
+
});
|
|
4266
|
+
|
|
3980
4267
|
// src/scan/scan.ts
|
|
3981
4268
|
import * as net2 from "node:net";
|
|
4269
|
+
function classifyFailure(error) {
|
|
4270
|
+
const text = String(error ?? "").trim();
|
|
4271
|
+
if (!text) return "\u672A\u77E5\u539F\u56E0";
|
|
4272
|
+
if (/timeout|timed out|超时|ETIMEDOUT/i.test(text)) return "\u8D85\u65F6";
|
|
4273
|
+
if (/ECONNREFUSED|connection refused|连接被拒/i.test(text)) return "\u8FDE\u63A5\u88AB\u62D2";
|
|
4274
|
+
if (/ENETUNREACH|EHOSTUNREACH|unreachable/i.test(text)) return "\u7F51\u7EDC\u4E0D\u53EF\u8FBE";
|
|
4275
|
+
if (/ECONNRESET|socket hang up|连接重置/i.test(text)) return "\u8FDE\u63A5\u91CD\u7F6E";
|
|
4276
|
+
if (/certificate|CERT_|SELF_SIGNED|证书/i.test(text)) return "\u8BC1\u4E66\u95EE\u9898";
|
|
4277
|
+
if (/ALPN/i.test(text)) return "ALPN \u534F\u5546\u5931\u8D25";
|
|
4278
|
+
if (/HTTP\s*\d{3}/i.test(text)) {
|
|
4279
|
+
const code = /HTTP\s*(\d{3})/i.exec(text)?.[1];
|
|
4280
|
+
return code ? `HTTP ${code}` : "HTTP \u72B6\u6001\u5F02\u5E38";
|
|
4281
|
+
}
|
|
4282
|
+
if (/PONG|pong/i.test(text)) return "\u5185\u5BB9\u6821\u9A8C\u4E0D\u901A\u8FC7";
|
|
4283
|
+
if (/ENOTFOUND|EAI_AGAIN|getaddrinfo/i.test(text)) return "\u57DF\u540D\u89E3\u6790\u5931\u8D25";
|
|
4284
|
+
return "\u5176\u4ED6";
|
|
4285
|
+
}
|
|
4286
|
+
function countFailure(into, stage, error) {
|
|
4287
|
+
const bucket = into[stage] ??= {};
|
|
4288
|
+
const key = classifyFailure(error);
|
|
4289
|
+
bucket[key] = (bucket[key] ?? 0) + 1;
|
|
4290
|
+
}
|
|
3982
4291
|
async function tcpPing(ip, port, timeoutMs) {
|
|
3983
|
-
return new Promise((
|
|
4292
|
+
return new Promise((resolve3) => {
|
|
3984
4293
|
const started = Date.now();
|
|
3985
4294
|
let settled = false;
|
|
3986
4295
|
const socket = new net2.Socket();
|
|
@@ -3991,7 +4300,7 @@ async function tcpPing(ip, port, timeoutMs) {
|
|
|
3991
4300
|
socket.destroy();
|
|
3992
4301
|
} catch {
|
|
3993
4302
|
}
|
|
3994
|
-
|
|
4303
|
+
resolve3({ ip, ok, latency: Date.now() - started });
|
|
3995
4304
|
};
|
|
3996
4305
|
socket.setTimeout(timeoutMs, () => done(false));
|
|
3997
4306
|
socket.once("connect", () => done(true));
|
|
@@ -4016,6 +4325,7 @@ async function pool(items, concurrency, worker, shouldStop) {
|
|
|
4016
4325
|
async function poolAdaptive(items, concurrency, worker, batchSize = 200) {
|
|
4017
4326
|
const out = [];
|
|
4018
4327
|
const maxConcurrency = Math.max(1, concurrency);
|
|
4328
|
+
const minConcurrency = Math.min(8, maxConcurrency);
|
|
4019
4329
|
let current = maxConcurrency;
|
|
4020
4330
|
for (let start = 0; start < items.length; start += batchSize) {
|
|
4021
4331
|
const batch = items.slice(start, start + batchSize);
|
|
@@ -4024,7 +4334,7 @@ async function poolAdaptive(items, concurrency, worker, batchSize = 200) {
|
|
|
4024
4334
|
const okCount = results.reduce((n, r) => n + (r.ok ? 1 : 0), 0);
|
|
4025
4335
|
const rate = results.length > 0 ? okCount / results.length : 1;
|
|
4026
4336
|
if (rate < 0.4) {
|
|
4027
|
-
current = Math.max(
|
|
4337
|
+
current = Math.max(minConcurrency, Math.min(maxConcurrency, Math.floor(current / 2)));
|
|
4028
4338
|
} else if (rate > 0.85) {
|
|
4029
4339
|
current = Math.min(maxConcurrency, current * 2);
|
|
4030
4340
|
}
|
|
@@ -4109,7 +4419,12 @@ async function runScan(options) {
|
|
|
4109
4419
|
}
|
|
4110
4420
|
return { ...item, tls: probe };
|
|
4111
4421
|
});
|
|
4422
|
+
const failures = {};
|
|
4112
4423
|
const tlsOk = tlsResults.filter((r) => r.tls.tlsMs > 0);
|
|
4424
|
+
for (const item of tlsResults) {
|
|
4425
|
+
if (item.tls.tlsMs > 0) continue;
|
|
4426
|
+
countFailure(failures, "tls", item.tls.error);
|
|
4427
|
+
}
|
|
4113
4428
|
const stage1 = tlsOk.sort((a, b) => a.tls.tlsMs - b.tls.tlsMs || a.latency - b.latency).slice(0, effectiveProbeLimit);
|
|
4114
4429
|
const strictProbe = options.verifyPayload !== false;
|
|
4115
4430
|
const explicitProbePath = options.probePath?.trim();
|
|
@@ -4167,6 +4482,10 @@ async function runScan(options) {
|
|
|
4167
4482
|
}
|
|
4168
4483
|
);
|
|
4169
4484
|
const wsOk = (strictProbe ? probeResults.filter((r) => r.probe.ok && r.probe.pongVerified === true) : probeResults.filter((r) => r.probe.ok)).filter((r) => r.pathOk !== false);
|
|
4485
|
+
for (const item of probeResults) {
|
|
4486
|
+
if (item.probe.ok) continue;
|
|
4487
|
+
countFailure(failures, "ws101", item.probe.error);
|
|
4488
|
+
}
|
|
4170
4489
|
let tunnelOk = wsOk;
|
|
4171
4490
|
let tunnelFailed = 0;
|
|
4172
4491
|
const tunnelCredential = options.uuid || options.trojanPassword;
|
|
@@ -4311,6 +4630,33 @@ async function runScan(options) {
|
|
|
4311
4630
|
(a, b) => options.skipSpeed ? a.tlsMs - b.tlsMs || a.latency - b.latency : b.speed - a.speed || a.tlsMs - b.tlsMs || a.latency - b.latency
|
|
4312
4631
|
);
|
|
4313
4632
|
const entries = pickWithDiversity(ranked, top);
|
|
4633
|
+
if (options.unlock && options.uuid && entries.length > 0) {
|
|
4634
|
+
const byColo = /* @__PURE__ */ new Map();
|
|
4635
|
+
for (const entry of entries) {
|
|
4636
|
+
const key = entry.colo || "UNK";
|
|
4637
|
+
if (!byColo.has(key)) byColo.set(key, entry);
|
|
4638
|
+
}
|
|
4639
|
+
const reps = [...byColo.values()];
|
|
4640
|
+
report({ type: "stage", stage: 4, name: "\u51FA\u53E3\u4F53\u68C0\uFF08\u6309\u673A\u623F\u53BB\u91CD\uFF09", total: reps.length });
|
|
4641
|
+
let done2 = 0;
|
|
4642
|
+
await pool(reps, 2, async (rep) => {
|
|
4643
|
+
const result = await probeUnlock({
|
|
4644
|
+
ip: rep.ip,
|
|
4645
|
+
port: options.port,
|
|
4646
|
+
host: options.host,
|
|
4647
|
+
token: options.uuid
|
|
4648
|
+
});
|
|
4649
|
+
done2++;
|
|
4650
|
+
report({
|
|
4651
|
+
type: "progress",
|
|
4652
|
+
stage: 4,
|
|
4653
|
+
done: done2,
|
|
4654
|
+
total: reps.length,
|
|
4655
|
+
message: `${rep.colo || "UNK"} ${describeUnlock(result)}`
|
|
4656
|
+
});
|
|
4657
|
+
return result;
|
|
4658
|
+
});
|
|
4659
|
+
}
|
|
4314
4660
|
for (const entry of entries) {
|
|
4315
4661
|
report({ type: "result", entry });
|
|
4316
4662
|
}
|
|
@@ -4329,7 +4675,9 @@ async function runScan(options) {
|
|
|
4329
4675
|
/** 国家筛选未命中任何候选、已放宽为全量 */
|
|
4330
4676
|
countryFilterRelaxed,
|
|
4331
4677
|
/** 因已攒够目标国家节点而提前结束阶段二 */
|
|
4332
|
-
stoppedEarly
|
|
4678
|
+
stoppedEarly,
|
|
4679
|
+
/** 各阶段失败原因分布 */
|
|
4680
|
+
failures
|
|
4333
4681
|
}
|
|
4334
4682
|
};
|
|
4335
4683
|
report({ type: "done", count: entries.length });
|
|
@@ -4379,6 +4727,7 @@ var init_scan = __esm({
|
|
|
4379
4727
|
init_true_probe();
|
|
4380
4728
|
init_speed_url();
|
|
4381
4729
|
init_countries();
|
|
4730
|
+
init_unlock();
|
|
4382
4731
|
}
|
|
4383
4732
|
});
|
|
4384
4733
|
|
|
@@ -4833,7 +5182,7 @@ var init_ip_ranges = __esm({
|
|
|
4833
5182
|
import * as net3 from "node:net";
|
|
4834
5183
|
import { execFile } from "node:child_process";
|
|
4835
5184
|
function isPortListening(port, timeoutMs = 400) {
|
|
4836
|
-
return new Promise((
|
|
5185
|
+
return new Promise((resolve3) => {
|
|
4837
5186
|
const socket = new net3.Socket();
|
|
4838
5187
|
let settled = false;
|
|
4839
5188
|
const done = (open) => {
|
|
@@ -4843,7 +5192,7 @@ function isPortListening(port, timeoutMs = 400) {
|
|
|
4843
5192
|
socket.destroy();
|
|
4844
5193
|
} catch {
|
|
4845
5194
|
}
|
|
4846
|
-
|
|
5195
|
+
resolve3(open);
|
|
4847
5196
|
};
|
|
4848
5197
|
socket.setTimeout(timeoutMs, () => done(false));
|
|
4849
5198
|
socket.once("connect", () => done(true));
|
|
@@ -4857,12 +5206,12 @@ function isPortListening(port, timeoutMs = 400) {
|
|
|
4857
5206
|
}
|
|
4858
5207
|
async function readSystemProxy() {
|
|
4859
5208
|
if (process.platform !== "win32") return "";
|
|
4860
|
-
const query = (key) => new Promise((
|
|
5209
|
+
const query = (key) => new Promise((resolve3) => {
|
|
4861
5210
|
execFile(
|
|
4862
5211
|
"reg",
|
|
4863
5212
|
["query", "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", "/v", key],
|
|
4864
5213
|
{ timeout: 3e3, windowsHide: true },
|
|
4865
|
-
(err, stdout2) =>
|
|
5214
|
+
(err, stdout2) => resolve3(err ? "" : String(stdout2))
|
|
4866
5215
|
);
|
|
4867
5216
|
});
|
|
4868
5217
|
try {
|
|
@@ -5221,12 +5570,12 @@ function startBridge(options = {}) {
|
|
|
5221
5570
|
sendJson(res, 500, { ok: false, error: err instanceof Error ? err.message : String(err) });
|
|
5222
5571
|
});
|
|
5223
5572
|
});
|
|
5224
|
-
return new Promise((
|
|
5573
|
+
return new Promise((resolve3, reject) => {
|
|
5225
5574
|
server.once("error", reject);
|
|
5226
5575
|
server.listen(port, host, () => {
|
|
5227
5576
|
const address = server.address();
|
|
5228
5577
|
const boundPort = typeof address === "object" && address !== null ? address.port : port;
|
|
5229
|
-
|
|
5578
|
+
resolve3({
|
|
5230
5579
|
server,
|
|
5231
5580
|
port: boundPort,
|
|
5232
5581
|
close: () => new Promise((done) => {
|
|
@@ -5478,7 +5827,9 @@ scan \u9009\u9879:
|
|
|
5478
5827
|
\u4E0E TCP \u5EF6\u8FDF\u51E0\u4E4E\u65E0\u5173\uFF08\u5B9E\u6D4B TCP 9ms \u7684 IP \u53EF\u80FD\u8981 3.5 \u79D2\uFF09\uFF0C
|
|
5479
5828
|
\u91C7\u6837\u5C0F\u4E86\u6839\u672C\u78B0\u4E0D\u5230\u63E1\u624B\u5FEB\u7684 IP
|
|
5480
5829
|
--countries <a,b> \u56FD\u5BB6 / \u5730\u533A\u8FC7\u6EE4\uFF08\u53EF\u591A\u9009\uFF0C\u9017\u53F7\u5206\u9694\uFF0C\u5982 US,JP,SG\uFF09
|
|
5481
|
-
\
|
|
5830
|
+
\u4E5F\u63A5\u53D7\u5206\u7EC4\u5173\u952E\u5B57\uFF1AASIA = \u4E9A\u6D32\u7EC4\u3001US = \u7F8E\u56FD\u7EC4\uFF0C
|
|
5831
|
+
\u53EF\u4E0E\u56FD\u5BB6\u7801\u6DF7\u5199\uFF08\u5982 ASIA,US\uFF09\uFF1B\u4E0D\u586B = \u5168\u91CF\u3002
|
|
5832
|
+
\u673A\u623F\u6765\u81EA 101 \u63E1\u624B\u54CD\u5E94\u3002
|
|
5482
5833
|
\u5E26\u6B64\u53C2\u6570\u4F1A\u81EA\u52A8\u6269\u5927 101 \u6821\u9A8C\u7684\u5019\u9009\u6C60\uFF08120 \u2192 \u6700\u591A 500\uFF09\uFF0C
|
|
5483
5834
|
\u5426\u5219\u76EE\u6807\u5730\u533A\u53EF\u80FD\u56E0\u5EF6\u8FDF\u6392\u5E8F\u88AB\u63D0\u524D\u622A\u65AD\uFF1B
|
|
5484
5835
|
\u7B5B\u4E0D\u5230\u65F6\u4F1A\u660E\u786E\u63D0\u793A\u300C\u5DF2\u653E\u5BBD\u4E3A\u5168\u91CF\u300D\u800C\u4E0D\u662F\u9759\u9ED8\u5FFD\u7565
|
|
@@ -5498,6 +5849,9 @@ scan \u9009\u9879:
|
|
|
5498
5849
|
--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
5850
|
--trojan-password <pw> \u771F\u5B9E\u96A7\u9053\u6821\u9A8C\u7528\u7684 Trojan \u53E3\u4EE4\uFF08\u4E0E --uuid \u4E8C\u9009\u4E00\uFF09
|
|
5500
5851
|
--verify-target <host> \u96A7\u9053\u6821\u9A8C\u8BBF\u95EE\u7684\u76EE\u6807\u57DF\u540D\uFF0C\u9ED8\u8BA4 baidu.com
|
|
5852
|
+
--unlock \u51FA\u53E3\u4F53\u68C0\uFF1A\u6309\u673A\u623F\u53BB\u91CD\uFF0C\u6807\u6CE8 [AI] / [NF]
|
|
5853
|
+
\u9700\u8981 --uuid\uFF08\u7AEF\u70B9\u9274\u6743\uFF09\u4E0E\u9762\u677F\u5F00\u542F\u300C\u51FA\u53E3\u4F53\u68C0\u300D\u5F00\u5173
|
|
5854
|
+
\u7ED3\u679C\u6309\u673A\u623F\u7F13\u5B58 10 \u5206\u949F\uFF0C\u540C\u4E00\u673A\u623F\u53EA\u6253\u4E00\u6B21\u5916\u90E8\u8BF7\u6C42
|
|
5501
5855
|
--no-verify-ws-path \u8DF3\u8FC7\u300C\u771F\u5B9E WS \u8DEF\u5F84 101\u300D\u8FD9\u9879\u989D\u5916\u6821\u9A8C
|
|
5502
5856
|
--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
|
|
5503
5857
|
\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
|
|
@@ -5551,6 +5905,9 @@ function normalizeWsPath(raw, fallback) {
|
|
|
5551
5905
|
}
|
|
5552
5906
|
return value;
|
|
5553
5907
|
}
|
|
5908
|
+
function seedFromArgs(args) {
|
|
5909
|
+
return args.flags["seed"] !== void 0 ? flagNumber(args, "seed", 24301) : void 0;
|
|
5910
|
+
}
|
|
5554
5911
|
async function resolveCandidatesFromArgs(args) {
|
|
5555
5912
|
const ipFile = flagString(args, "ip-file");
|
|
5556
5913
|
if (ipFile) {
|
|
@@ -5565,7 +5922,7 @@ async function resolveCandidatesFromArgs(args) {
|
|
|
5565
5922
|
cidr: flagList(args, "cidr"),
|
|
5566
5923
|
// ⚠️ 不传 seed = 每次随机(默认)。只有用户显式给了 --seed 才固定,
|
|
5567
5924
|
// 否则「每次跑都测同一批 IP」——那批落在劣质路由段上时永远测不出好 IP。
|
|
5568
|
-
seed:
|
|
5925
|
+
seed: seedFromArgs(args)
|
|
5569
5926
|
});
|
|
5570
5927
|
}
|
|
5571
5928
|
function printProgress(event, quiet) {
|
|
@@ -5604,12 +5961,23 @@ function printTable(entries) {
|
|
|
5604
5961
|
const rank = String(index + 1).padStart(2, " ");
|
|
5605
5962
|
const address = `${formatHost(entry.ip)}:${entry.port}`.padEnd(24, " ");
|
|
5606
5963
|
const colo = (entry.colo || "UNK").padEnd(6, " ");
|
|
5607
|
-
const
|
|
5964
|
+
const tls4 = String(entry.tlsMs).padStart(7, " ");
|
|
5608
5965
|
const latency = String(entry.latency).padStart(7, " ");
|
|
5609
5966
|
const speed = entry.speed.toFixed(1).padStart(9, " ");
|
|
5610
|
-
process.stdout.write(`${rank} ${address} ${colo} ${
|
|
5967
|
+
process.stdout.write(`${rank} ${address} ${colo} ${tls4} ${latency} ${speed}
|
|
5611
5968
|
`);
|
|
5612
5969
|
});
|
|
5970
|
+
const seen = [];
|
|
5971
|
+
for (const entry of entries) {
|
|
5972
|
+
const colo = entry.colo || "UNK";
|
|
5973
|
+
if (!seen.includes(colo)) seen.push(colo);
|
|
5974
|
+
}
|
|
5975
|
+
const named = seen.filter((c2) => coloCity(c2));
|
|
5976
|
+
if (named.length > 0) {
|
|
5977
|
+
process.stdout.write(
|
|
5978
|
+
"\n\u673A\u623F\u5BF9\u7167\uFF1A" + named.map((c2) => `${c2}=${coloCity(c2)}`).join(" ") + "\n"
|
|
5979
|
+
);
|
|
5980
|
+
}
|
|
5613
5981
|
}
|
|
5614
5982
|
function printCopyable(entries) {
|
|
5615
5983
|
if (entries.length === 0) return;
|
|
@@ -5708,9 +6076,11 @@ ${NAME} v${VERSION}
|
|
|
5708
6076
|
`);
|
|
5709
6077
|
}
|
|
5710
6078
|
}
|
|
5711
|
-
|
|
6079
|
+
let envResult = null;
|
|
6080
|
+
if (!quiet || asJson) {
|
|
5712
6081
|
const env = await detectProxyInterference(host);
|
|
5713
|
-
|
|
6082
|
+
envResult = env;
|
|
6083
|
+
if (!quiet && !env.clean) {
|
|
5714
6084
|
process.stdout.write("\n\u26A0\uFE0F \u68C0\u6D4B\u5230\u53EF\u80FD\u5E72\u6270\u4F18\u9009\u7684\u56E0\u7D20\uFF1A\n");
|
|
5715
6085
|
for (const f of env.findings) {
|
|
5716
6086
|
process.stdout.write(` ${f.message}
|
|
@@ -5825,13 +6195,42 @@ ${NAME} v${VERSION}
|
|
|
5825
6195
|
verifyTargetHost: flagString(args, "verify-target"),
|
|
5826
6196
|
verifyTargetPort: flagNumber(args, "verify-target-port", 80),
|
|
5827
6197
|
speedRepeat: flagNumber(args, "speed-repeat", 1),
|
|
6198
|
+
// 出口体检(可选):需要 --uuid 做端点鉴权,按机房去重调用
|
|
6199
|
+
unlock: flagBool(args, "unlock"),
|
|
5828
6200
|
verifyWsPath: args.flags["no-verify-ws-path"] === void 0,
|
|
5829
6201
|
top,
|
|
5830
6202
|
onProgress: (event) => printProgress(event, quiet)
|
|
5831
6203
|
});
|
|
5832
6204
|
if (asJson) {
|
|
5833
6205
|
process.stdout.write(
|
|
5834
|
-
`${JSON.stringify(
|
|
6206
|
+
`${JSON.stringify(
|
|
6207
|
+
{
|
|
6208
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6209
|
+
tool: "cfpilot",
|
|
6210
|
+
version: VERSION,
|
|
6211
|
+
seed: seedFromArgs(args) ?? null,
|
|
6212
|
+
params: {
|
|
6213
|
+
host,
|
|
6214
|
+
port,
|
|
6215
|
+
wsPath,
|
|
6216
|
+
probePath,
|
|
6217
|
+
sample: flagNumber(args, "sample", 6556),
|
|
6218
|
+
top,
|
|
6219
|
+
countries: summary.stats.countries,
|
|
6220
|
+
speedMode,
|
|
6221
|
+
speedLimit: flagNumber(args, "speed-limit", 30),
|
|
6222
|
+
speedBytes: flagNumber(args, "speed-bytes", 5 * 1024 * 1024),
|
|
6223
|
+
skipSpeed,
|
|
6224
|
+
verifyPayload,
|
|
6225
|
+
tunnelVerified: Boolean(flagString(args, "uuid") || flagString(args, "trojan-password"))
|
|
6226
|
+
},
|
|
6227
|
+
env: envResult,
|
|
6228
|
+
stats: summary.stats,
|
|
6229
|
+
entries: summary.entries
|
|
6230
|
+
},
|
|
6231
|
+
null,
|
|
6232
|
+
2
|
|
6233
|
+
)}
|
|
5835
6234
|
`
|
|
5836
6235
|
);
|
|
5837
6236
|
} else {
|
|
@@ -6028,11 +6427,21 @@ async function menuScan() {
|
|
|
6028
6427
|
const wantFilter = await confirm("\u8981\u6309\u673A\u623F\u5730\u533A\u7B5B\u9009\u5417\uFF1F\uFF08\u4E0D\u7B5B\u9009\u8DD1\u5168\u91CF\uFF09", false);
|
|
6029
6428
|
let countries = [];
|
|
6030
6429
|
if (wantFilter) {
|
|
6430
|
+
const CLEAR = "__CLEAR__";
|
|
6431
|
+
const GROUP = "GROUP:";
|
|
6031
6432
|
const picked = await multiSelect(
|
|
6032
6433
|
"\u9009\u62E9\u5730\u533A\uFF08\u7A7A\u683C\u5207\u6362\uFF0CEnter \u786E\u8BA4\uFF09",
|
|
6033
|
-
|
|
6434
|
+
[
|
|
6435
|
+
{ label: "\u53D6\u6D88\u9009\u62E9\uFF08\u4E0D\u9009 = \u5168\u90E8\uFF09", value: CLEAR },
|
|
6436
|
+
...Object.entries(REGION_GROUP_NAMES).map(([key, name]) => ({
|
|
6437
|
+
label: name,
|
|
6438
|
+
hint: `\u5C55\u5F00\u4E3A ${REGION_GROUPS[key]?.length ?? 0} \u4E2A\u56FD\u5BB6`,
|
|
6439
|
+
value: GROUP + key
|
|
6440
|
+
})),
|
|
6441
|
+
...SUPPORTED_COUNTRIES.map((code) => ({ label: code, value: code }))
|
|
6442
|
+
]
|
|
6034
6443
|
);
|
|
6035
|
-
countries = picked;
|
|
6444
|
+
countries = picked.includes(CLEAR) ? [] : picked.map((v) => v.startsWith(GROUP) ? v.slice(GROUP.length) : v);
|
|
6036
6445
|
}
|
|
6037
6446
|
const sampleStr = await ask("\u91C7\u6837\u6570\u91CF", { fallback: "6556" });
|
|
6038
6447
|
const sample = Number(sampleStr) || 6556;
|
|
@@ -6556,6 +6965,241 @@ var init_main = __esm({
|
|
|
6556
6965
|
}
|
|
6557
6966
|
});
|
|
6558
6967
|
|
|
6968
|
+
// src/scan/single.ts
|
|
6969
|
+
import * as net4 from "node:net";
|
|
6970
|
+
function probeTcp(ip, port, timeoutMs) {
|
|
6971
|
+
return new Promise((resolve3) => {
|
|
6972
|
+
const started = Date.now();
|
|
6973
|
+
let settled = false;
|
|
6974
|
+
const finish = (result) => {
|
|
6975
|
+
if (settled) return;
|
|
6976
|
+
settled = true;
|
|
6977
|
+
try {
|
|
6978
|
+
socket.destroy();
|
|
6979
|
+
} catch {
|
|
6980
|
+
}
|
|
6981
|
+
resolve3({ stage: "TCP \u5EFA\u8FDE", ms: Date.now() - started, ...result });
|
|
6982
|
+
};
|
|
6983
|
+
const socket = net4.connect({ host: ip, port });
|
|
6984
|
+
socket.setTimeout(timeoutMs, () => finish({ ok: false, error: "\u8D85\u65F6" }));
|
|
6985
|
+
socket.once("connect", () => finish({ ok: true }));
|
|
6986
|
+
socket.once("error", (err) => finish({ ok: false, error: err.message }));
|
|
6987
|
+
});
|
|
6988
|
+
}
|
|
6989
|
+
async function runSingleTest(options) {
|
|
6990
|
+
const {
|
|
6991
|
+
ip,
|
|
6992
|
+
port,
|
|
6993
|
+
host,
|
|
6994
|
+
path,
|
|
6995
|
+
timeoutMs,
|
|
6996
|
+
speed,
|
|
6997
|
+
speedBytes,
|
|
6998
|
+
uuid,
|
|
6999
|
+
trojanPassword,
|
|
7000
|
+
verifyTargetHost,
|
|
7001
|
+
verifyTargetPort,
|
|
7002
|
+
onStage
|
|
7003
|
+
} = options;
|
|
7004
|
+
const results = [];
|
|
7005
|
+
const push = (result) => {
|
|
7006
|
+
results.push(result);
|
|
7007
|
+
onStage?.(result);
|
|
7008
|
+
};
|
|
7009
|
+
const tcp = await probeTcp(ip, port, timeoutMs);
|
|
7010
|
+
push(tcp);
|
|
7011
|
+
if (!tcp.ok) return results;
|
|
7012
|
+
const tls4 = await probeTlsHandshake(ip, port, host, timeoutMs);
|
|
7013
|
+
const tlsOk = tls4.tlsMs >= 0 && !tls4.error;
|
|
7014
|
+
push({
|
|
7015
|
+
stage: "TLS \u63E1\u624B",
|
|
7016
|
+
ok: tlsOk,
|
|
7017
|
+
ms: tls4.tlsMs >= 0 ? tls4.tlsMs : void 0,
|
|
7018
|
+
detail: tls4.alpn ? `ALPN=${tls4.alpn}` : void 0,
|
|
7019
|
+
error: tlsOk ? void 0 : tls4.error ?? "\u63E1\u624B\u5931\u8D25"
|
|
7020
|
+
});
|
|
7021
|
+
if (!tlsOk) return results;
|
|
7022
|
+
const ws = await probeWs101(ip, port, host, timeoutMs, path);
|
|
7023
|
+
push({
|
|
7024
|
+
stage: "WebSocket 101",
|
|
7025
|
+
ok: ws.ok,
|
|
7026
|
+
ms: ws.latencyMs,
|
|
7027
|
+
detail: ws.colo ? `\u673A\u623F ${ws.colo}` : void 0,
|
|
7028
|
+
error: ws.ok ? void 0 : ws.error ?? `HTTP ${ws.status}`
|
|
7029
|
+
});
|
|
7030
|
+
if (!ws.ok) return results;
|
|
7031
|
+
const ping = await probeWsPing(ip, port, host, timeoutMs, path);
|
|
7032
|
+
push({
|
|
7033
|
+
stage: "PONG \u5185\u5BB9\u6821\u9A8C",
|
|
7034
|
+
ok: ping.ok,
|
|
7035
|
+
ms: ping.latencyMs,
|
|
7036
|
+
detail: ping.probeColo ? `\u673A\u623F ${ping.probeColo}` : void 0,
|
|
7037
|
+
error: ping.ok ? void 0 : ping.error ?? "\u672A\u6536\u5230 PONG"
|
|
7038
|
+
});
|
|
7039
|
+
if (speed) {
|
|
7040
|
+
const throughput = await measureProbeThroughput({
|
|
7041
|
+
ip,
|
|
7042
|
+
port,
|
|
7043
|
+
host,
|
|
7044
|
+
bytes: speedBytes,
|
|
7045
|
+
path,
|
|
7046
|
+
connections: 8,
|
|
7047
|
+
durationMs: 6e3,
|
|
7048
|
+
timeoutMs: Math.max(timeoutMs, 15e3),
|
|
7049
|
+
token: uuid
|
|
7050
|
+
});
|
|
7051
|
+
push({
|
|
7052
|
+
stage: "\u4E0B\u884C\u6D4B\u901F",
|
|
7053
|
+
ok: throughput.ok,
|
|
7054
|
+
detail: throughput.ok ? `${throughput.steadyMBps.toFixed(2)} MB/s\uFF08\u7A33\u6001\uFF09` : void 0,
|
|
7055
|
+
error: throughput.ok ? void 0 : throughput.error ?? "\u6D4B\u901F\u5931\u8D25"
|
|
7056
|
+
});
|
|
7057
|
+
}
|
|
7058
|
+
if (uuid || trojanPassword) {
|
|
7059
|
+
const tunnel = await verifyTunnel({
|
|
7060
|
+
ip,
|
|
7061
|
+
port,
|
|
7062
|
+
host,
|
|
7063
|
+
wsPath: path,
|
|
7064
|
+
uuid,
|
|
7065
|
+
trojanPassword,
|
|
7066
|
+
targetHost: verifyTargetHost,
|
|
7067
|
+
targetPort: verifyTargetPort,
|
|
7068
|
+
timeoutMs: Math.max(timeoutMs, 8e3)
|
|
7069
|
+
});
|
|
7070
|
+
push({
|
|
7071
|
+
stage: "\u771F\u5B9E\u96A7\u9053",
|
|
7072
|
+
ok: tunnel.ok,
|
|
7073
|
+
ms: tunnel.latencyMs,
|
|
7074
|
+
detail: tunnel.ok ? `\u8BBF\u95EE ${verifyTargetHost} \u6536\u5230\u6570\u636E` : void 0,
|
|
7075
|
+
error: tunnel.ok ? void 0 : `${tunnel.stage ?? "\u672A\u77E5\u9636\u6BB5"}\uFF1A${tunnel.error ?? "\u5931\u8D25"}`
|
|
7076
|
+
});
|
|
7077
|
+
}
|
|
7078
|
+
return results;
|
|
7079
|
+
}
|
|
7080
|
+
function summarizeStages(results) {
|
|
7081
|
+
const failed = results.find((r) => !r.ok);
|
|
7082
|
+
if (!failed) return `\u5168\u90E8 ${results.length} \u9879\u901A\u8FC7`;
|
|
7083
|
+
return `\u5361\u5728\u300C${failed.stage}\u300D\uFF1A${failed.error ?? "\u672A\u77E5\u539F\u56E0"}`;
|
|
7084
|
+
}
|
|
7085
|
+
var init_single = __esm({
|
|
7086
|
+
"src/scan/single.ts"() {
|
|
7087
|
+
"use strict";
|
|
7088
|
+
init_true_probe();
|
|
7089
|
+
}
|
|
7090
|
+
});
|
|
7091
|
+
|
|
7092
|
+
// src/scan/single-command.ts
|
|
7093
|
+
var single_command_exports = {};
|
|
7094
|
+
__export(single_command_exports, {
|
|
7095
|
+
runTestCommand: () => runTestCommand
|
|
7096
|
+
});
|
|
7097
|
+
function mark(ok) {
|
|
7098
|
+
return ok ? "\x1B[32m\u2713\x1B[0m" : "\x1B[31m\u2717\x1B[0m";
|
|
7099
|
+
}
|
|
7100
|
+
function printStage(result) {
|
|
7101
|
+
const parts = [` ${mark(result.ok)} ${result.stage}`];
|
|
7102
|
+
if (result.ms !== void 0) parts.push(`${result.ms} ms`);
|
|
7103
|
+
if (result.detail) parts.push(result.detail);
|
|
7104
|
+
if (result.error) parts.push(`\x1B[31m${result.error}\x1B[0m`);
|
|
7105
|
+
process.stdout.write(parts.join(" ") + "\n");
|
|
7106
|
+
}
|
|
7107
|
+
async function runTestCommand(args) {
|
|
7108
|
+
if (flagBool(args, "h") || flagBool(args, "help")) {
|
|
7109
|
+
process.stdout.write(HELP);
|
|
7110
|
+
return;
|
|
7111
|
+
}
|
|
7112
|
+
const host = flagString(args, "host").trim();
|
|
7113
|
+
const ip = flagString(args, "ip").trim();
|
|
7114
|
+
if (!host || !ip) {
|
|
7115
|
+
process.stderr.write("\u7F3A\u5C11\u53C2\u6570\uFF1A--host \u4E0E --ip \u90FD\u662F\u5FC5\u586B\n\n" + HELP);
|
|
7116
|
+
process.exitCode = 1;
|
|
7117
|
+
return;
|
|
7118
|
+
}
|
|
7119
|
+
const port = flagNumber(args, "port", 443);
|
|
7120
|
+
if (port < 1 || port > 65535) {
|
|
7121
|
+
process.stderr.write(`\u7AEF\u53E3 ${port} \u8D85\u51FA\u8303\u56F4\uFF081-65535\uFF09
|
|
7122
|
+
`);
|
|
7123
|
+
process.exitCode = 1;
|
|
7124
|
+
return;
|
|
7125
|
+
}
|
|
7126
|
+
const asJson = flagBool(args, "json");
|
|
7127
|
+
const options = {
|
|
7128
|
+
ip,
|
|
7129
|
+
port,
|
|
7130
|
+
host,
|
|
7131
|
+
path: flagString(args, "path", "/__edge_probe"),
|
|
7132
|
+
timeoutMs: flagNumber(args, "timeout", 4e3),
|
|
7133
|
+
speed: flagBool(args, "speed"),
|
|
7134
|
+
speedBytes: flagNumber(args, "speed-bytes", 5 * 1024 * 1024),
|
|
7135
|
+
uuid: flagString(args, "uuid").trim() || void 0,
|
|
7136
|
+
trojanPassword: flagString(args, "trojan-password").trim() || void 0,
|
|
7137
|
+
verifyTargetHost: flagString(args, "verify-target", "baidu.com"),
|
|
7138
|
+
verifyTargetPort: flagNumber(args, "verify-target-port", 80)
|
|
7139
|
+
};
|
|
7140
|
+
if (!asJson) {
|
|
7141
|
+
process.stdout.write(`
|
|
7142
|
+
\u6D4B\u8BD5 ${ip}:${port} \u2192 ${host}${options.path}
|
|
7143
|
+
|
|
7144
|
+
`);
|
|
7145
|
+
}
|
|
7146
|
+
const results = await runSingleTest({
|
|
7147
|
+
...options,
|
|
7148
|
+
onStage: asJson ? void 0 : printStage
|
|
7149
|
+
});
|
|
7150
|
+
const summary = summarizeStages(results);
|
|
7151
|
+
if (asJson) {
|
|
7152
|
+
process.stdout.write(
|
|
7153
|
+
`${JSON.stringify({ ip, port, host, path: options.path, results, summary }, null, 2)}
|
|
7154
|
+
`
|
|
7155
|
+
);
|
|
7156
|
+
} else {
|
|
7157
|
+
process.stdout.write(`
|
|
7158
|
+
\u7ED3\u8BBA\uFF1A${summary}
|
|
7159
|
+
`);
|
|
7160
|
+
}
|
|
7161
|
+
if (results.some((r) => !r.ok)) process.exitCode = 1;
|
|
7162
|
+
}
|
|
7163
|
+
var HELP;
|
|
7164
|
+
var init_single_command = __esm({
|
|
7165
|
+
"src/scan/single-command.ts"() {
|
|
7166
|
+
"use strict";
|
|
7167
|
+
init_args();
|
|
7168
|
+
init_version();
|
|
7169
|
+
init_single();
|
|
7170
|
+
HELP = `
|
|
7171
|
+
${NAME} test \u2014\u2014 \u6D4B\u8BD5\u5355\u4E2A IP \u7684\u5B8C\u6574\u94FE\u8DEF
|
|
7172
|
+
|
|
7173
|
+
\u7528\u6CD5:
|
|
7174
|
+
${NAME} test --host <\u6570\u636E\u9762\u57DF\u540D> --ip <IP> [\u9009\u9879]
|
|
7175
|
+
|
|
7176
|
+
\u5FC5\u586B:
|
|
7177
|
+
--host <domain> \u6570\u636E\u9762\u57DF\u540D\uFF08\u4F5C\u4E3A TLS SNI \u4E0E HTTP Host\uFF09
|
|
7178
|
+
--ip <address> \u8981\u6D4B\u8BD5\u7684 IP\uFF08IPv6 \u76F4\u63A5\u5199\uFF0C\u4E0D\u52A0\u65B9\u62EC\u53F7\uFF09
|
|
7179
|
+
|
|
7180
|
+
\u9009\u9879:
|
|
7181
|
+
--port <port> \u7AEF\u53E3\uFF0C\u9ED8\u8BA4 443
|
|
7182
|
+
--path <path> WebSocket \u6821\u9A8C\u8DEF\u5F84\uFF0C\u9ED8\u8BA4 /__edge_probe
|
|
7183
|
+
--timeout <ms> \u5355\u9636\u6BB5\u8D85\u65F6\uFF0C\u9ED8\u8BA4 4000
|
|
7184
|
+
--speed \u989D\u5916\u505A\u4E0B\u884C\u6D4B\u901F\uFF08\u4F1A\u6D88\u8017\u6D41\u91CF\uFF0C\u9ED8\u8BA4\u5173\u95ED\uFF09
|
|
7185
|
+
--speed-bytes <n> \u6D4B\u901F\u8BF7\u6C42\u5B57\u8282\u6570\uFF0C\u9ED8\u8BA4 5242880\uFF085 MiB\uFF09
|
|
7186
|
+
--uuid <uuid> \u771F\u5B9E\u96A7\u9053\u6821\u9A8C\u7528\u7684 VLESS UUID
|
|
7187
|
+
--trojan-password <pw> \u771F\u5B9E\u96A7\u9053\u6821\u9A8C\u7528\u7684 Trojan \u53E3\u4EE4\uFF08\u4E0E --uuid \u4E8C\u9009\u4E00\uFF09
|
|
7188
|
+
--verify-target <host> \u96A7\u9053\u6821\u9A8C\u8BBF\u95EE\u7684\u76EE\u6807\uFF0C\u9ED8\u8BA4 baidu.com
|
|
7189
|
+
--json \u4EE5 JSON \u8F93\u51FA\uFF08\u4FBF\u4E8E\u811A\u672C\u5904\u7406\uFF09
|
|
7190
|
+
-h, --help \u663E\u793A\u672C\u5E2E\u52A9
|
|
7191
|
+
|
|
7192
|
+
\u793A\u4F8B:
|
|
7193
|
+
${NAME} test --host cf.example.com --ip 104.16.1.1
|
|
7194
|
+
${NAME} test --host cf.example.com --ip 104.16.1.1 --speed --uuid <UUID>
|
|
7195
|
+
|
|
7196
|
+
\u8BF4\u660E:
|
|
7197
|
+
\u9636\u6BB5\u987A\u5E8F\u4E0E\u5BA2\u6237\u7AEF\u771F\u5B9E\u5EFA\u8FDE\u4E00\u81F4\uFF1ATCP \u2192 TLS \u2192 WS 101 \u2192 PONG \u2192 \u6D4B\u901F \u2192 \u96A7\u9053\u3002
|
|
7198
|
+
\u524D\u4E00\u9636\u6BB5\u5931\u8D25\u5373\u505C\u6B62\uFF08\u540E\u9762\u7684\u9636\u6BB5\u4F9D\u8D56\u5B83\uFF0C\u7EE7\u7EED\u8DD1\u53EA\u4F1A\u5F97\u5230\u4E00\u4E32\u300C\u4E5F\u5931\u8D25\u300D\uFF09\u3002
|
|
7199
|
+
`;
|
|
7200
|
+
}
|
|
7201
|
+
});
|
|
7202
|
+
|
|
6559
7203
|
// src/deploy/token-command.ts
|
|
6560
7204
|
var token_command_exports = {};
|
|
6561
7205
|
__export(token_command_exports, {
|
|
@@ -6614,10 +7258,141 @@ var init_token_command = __esm({
|
|
|
6614
7258
|
}
|
|
6615
7259
|
});
|
|
6616
7260
|
|
|
7261
|
+
// src/vps/command.ts
|
|
7262
|
+
var command_exports3 = {};
|
|
7263
|
+
__export(command_exports3, {
|
|
7264
|
+
runVpsCommand: () => runVpsCommand
|
|
7265
|
+
});
|
|
7266
|
+
import { spawn } from "node:child_process";
|
|
7267
|
+
import { existsSync as existsSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "node:fs";
|
|
7268
|
+
import { dirname as dirname2, resolve as resolve2 } from "node:path";
|
|
7269
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
7270
|
+
function loadScript() {
|
|
7271
|
+
const here = dirname2(fileURLToPath2(import.meta.url));
|
|
7272
|
+
const candidates = [
|
|
7273
|
+
resolve2(here, "../assets/vps-socks5.sh"),
|
|
7274
|
+
resolve2(here, "../../assets/vps-socks5.sh")
|
|
7275
|
+
];
|
|
7276
|
+
for (const path of candidates) {
|
|
7277
|
+
if (existsSync2(path)) return readFileSync3(path, "utf8");
|
|
7278
|
+
}
|
|
7279
|
+
throw new Error("\u5185\u7F6E\u811A\u672C\u7F3A\u5931\uFF08assets/vps-socks5.sh\uFF09\uFF0C\u8BF7\u91CD\u65B0\u5B89\u88C5\u6216\u5347\u7EA7 cfpilot");
|
|
7280
|
+
}
|
|
7281
|
+
function withPort(script, port) {
|
|
7282
|
+
if (!port || !Number.isInteger(port) || port <= 0 || port > 65535) return script;
|
|
7283
|
+
return script.replace(/^PORT=1080$/m, `PORT=${port}`);
|
|
7284
|
+
}
|
|
7285
|
+
function runSsh(host, script) {
|
|
7286
|
+
return new Promise((resolvePromise) => {
|
|
7287
|
+
const child = spawn("ssh", ["-t", "-o", "StrictHostKeyChecking=accept-new", host, "bash -s"], {
|
|
7288
|
+
stdio: ["pipe", "inherit", "inherit"]
|
|
7289
|
+
});
|
|
7290
|
+
child.on("error", (err) => {
|
|
7291
|
+
if (err.code === "ENOENT") {
|
|
7292
|
+
process.stderr.write(
|
|
7293
|
+
"\n\u672C\u673A\u6CA1\u6709\u627E\u5230 ssh \u5BA2\u6237\u7AEF\u3002\n\xB7 Windows\uFF1A\u8BBE\u7F6E \u2192 \u5E94\u7528 \u2192 \u53EF\u9009\u529F\u80FD \u2192 \u6DFB\u52A0\u300COpenSSH \u5BA2\u6237\u7AEF\u300D\n\xB7 \u6216\u8005\u6539\u7528\uFF1Acfpilot vps\uFF08\u751F\u6210\u811A\u672C\u540E\u624B\u52A8 scp \u5230 VPS \u6267\u884C\uFF09\n\n"
|
|
7294
|
+
);
|
|
7295
|
+
} else {
|
|
7296
|
+
process.stderr.write(`
|
|
7297
|
+
ssh \u542F\u52A8\u5931\u8D25\uFF1A${err.message}
|
|
7298
|
+
`);
|
|
7299
|
+
}
|
|
7300
|
+
resolvePromise(1);
|
|
7301
|
+
});
|
|
7302
|
+
child.on("close", (code) => resolvePromise(code ?? 1));
|
|
7303
|
+
child.stdin.write(script);
|
|
7304
|
+
child.stdin.end();
|
|
7305
|
+
});
|
|
7306
|
+
}
|
|
7307
|
+
async function runVpsCommand(args) {
|
|
7308
|
+
if (flagBool(args, "h") || flagBool(args, "help")) {
|
|
7309
|
+
process.stdout.write(HELP2);
|
|
7310
|
+
return;
|
|
7311
|
+
}
|
|
7312
|
+
const port = flagNumber(args, "port", 0);
|
|
7313
|
+
const script = withPort(loadScript(), port > 0 ? port : void 0);
|
|
7314
|
+
if (flagBool(args, "print")) {
|
|
7315
|
+
process.stdout.write(script);
|
|
7316
|
+
return;
|
|
7317
|
+
}
|
|
7318
|
+
const sshHost = flagString(args, "ssh").trim();
|
|
7319
|
+
if (sshHost) {
|
|
7320
|
+
process.stdout.write(`
|
|
7321
|
+
\u6B63\u5728\u901A\u8FC7 ssh \u5728 ${sshHost} \u4E0A\u6267\u884C\u90E8\u7F72\u811A\u672C\u2026
|
|
7322
|
+
`);
|
|
7323
|
+
process.stdout.write("\uFF08\u9996\u6B21\u8FDE\u63A5\u4F1A\u63D0\u793A\u786E\u8BA4\u4E3B\u673A\u6307\u7EB9\uFF1B\u811A\u672C\u9700\u8981 root\uFF0C\u5FC5\u8981\u65F6\u4F1A\u8981\u6C42\u8F93\u5165 sudo \u5BC6\u7801\uFF09\n\n");
|
|
7324
|
+
const code = await runSsh(sshHost, script);
|
|
7325
|
+
if (code !== 0) {
|
|
7326
|
+
process.stderr.write(`
|
|
7327
|
+
\u8FDC\u7A0B\u6267\u884C\u5931\u8D25\uFF08\u9000\u51FA\u7801 ${code}\uFF09\u3002\u53EF\u6539\u7528 cfpilot vps \u751F\u6210\u811A\u672C\u540E\u624B\u52A8\u6267\u884C\u3002
|
|
7328
|
+
`);
|
|
7329
|
+
process.exitCode = code;
|
|
7330
|
+
}
|
|
7331
|
+
return;
|
|
7332
|
+
}
|
|
7333
|
+
const out = resolve2(process.cwd(), flagString(args, "out") ?? "cfpilot-vps-socks5.sh");
|
|
7334
|
+
writeFileSync2(out, script, { mode: 493 });
|
|
7335
|
+
process.stdout.write(
|
|
7336
|
+
`
|
|
7337
|
+
\u5DF2\u751F\u6210\u811A\u672C\uFF1A${out}
|
|
7338
|
+
|
|
7339
|
+
\u63A5\u4E0B\u6765\u4E8C\u9009\u4E00\uFF1A
|
|
7340
|
+
|
|
7341
|
+
\u2460 \u6709 ssh \u5BA2\u6237\u7AEF\uFF08\u63A8\u8350\uFF09
|
|
7342
|
+
scp cfpilot-vps-socks5.sh root@\u4F60\u7684VPS_IP:/tmp/
|
|
7343
|
+
ssh -t root@\u4F60\u7684VPS_IP "bash /tmp/cfpilot-vps-socks5.sh"
|
|
7344
|
+
|
|
7345
|
+
\u2461 \u5728 VPS \u4E0A\u624B\u52A8\u6267\u884C
|
|
7346
|
+
\u628A\u811A\u672C\u4F20\u4E0A\u53BB\uFF0C\u7136\u540E\uFF1Asudo bash /tmp/cfpilot-vps-socks5.sh
|
|
7347
|
+
|
|
7348
|
+
\u8DD1\u5B8C\u4F1A\u6253\u5370\u4E00\u884C socks5://\u7528\u6237\u540D:\u53E3\u4EE4@IP:\u7AEF\u53E3\uFF0C
|
|
7349
|
+
\u7C98\u8FDB CFPilot \u9762\u677F\u300C\u51FA\u7AD9\u4E0E\u9AD8\u7EA7\u300D\u2192 SOCKS5 \u5373\u53EF\u3002
|
|
7350
|
+
|
|
7351
|
+
\u63D0\u793A\uFF1A\u4E5F\u53EF\u4EE5\u76F4\u63A5 ${NAME} vps --ssh root@\u4F60\u7684VPS_IP\uFF0C\u7531\u672C\u5DE5\u5177\u4EE3\u8DD1\u3002
|
|
7352
|
+
|
|
7353
|
+
`
|
|
7354
|
+
);
|
|
7355
|
+
}
|
|
7356
|
+
var HELP2;
|
|
7357
|
+
var init_command3 = __esm({
|
|
7358
|
+
"src/vps/command.ts"() {
|
|
7359
|
+
"use strict";
|
|
7360
|
+
init_args();
|
|
7361
|
+
init_version();
|
|
7362
|
+
HELP2 = `
|
|
7363
|
+
${NAME} vps \u2014\u2014 \u5728\u81EA\u5DF1\u7684 VPS \u4E0A\u90E8\u7F72 SOCKS5 \u843D\u5730\u4EE3\u7406
|
|
7364
|
+
|
|
7365
|
+
\u7528\u6CD5:
|
|
7366
|
+
${NAME} vps [\u9009\u9879]
|
|
7367
|
+
|
|
7368
|
+
\u9009\u9879:
|
|
7369
|
+
--ssh <user@host> \u76F4\u63A5\u901A\u8FC7\u7CFB\u7EDF ssh \u8FDC\u7A0B\u6267\u884C\uFF08\u9700\u672C\u673A\u6709 ssh \u5BA2\u6237\u7AEF\uFF09
|
|
7370
|
+
--port <\u7AEF\u53E3> SOCKS5 \u76D1\u542C\u7AEF\u53E3\uFF0C\u9ED8\u8BA4 1080
|
|
7371
|
+
--out <\u8DEF\u5F84> \u811A\u672C\u843D\u5730\u8DEF\u5F84\uFF0C\u9ED8\u8BA4 ./cfpilot-vps-socks5.sh
|
|
7372
|
+
--print \u53EA\u628A\u811A\u672C\u8F93\u51FA\u5230\u6807\u51C6\u8F93\u51FA\uFF08\u81EA\u5DF1\u5BA1\u8BA1 / \u624B\u5DE5\u6267\u884C\uFF09
|
|
7373
|
+
-h, --help \u663E\u793A\u672C\u5E2E\u52A9
|
|
7374
|
+
|
|
7375
|
+
\u8BF4\u660E:
|
|
7376
|
+
\u90E8\u7F72\u5B8C\u6210\u540E\u4F1A\u6253\u5370\u4E00\u884C socks5://\u7528\u6237\u540D:\u53E3\u4EE4@IP:\u7AEF\u53E3\uFF0C
|
|
7377
|
+
\u7C98\u8FDB CFPilot \u9762\u677F\u300C\u51FA\u7AD9\u4E0E\u9AD8\u7EA7\u300D\u7684 SOCKS5 \u8F93\u5165\u6846\u5373\u53EF\u3002
|
|
7378
|
+
|
|
7379
|
+
\u811A\u672C\u505A\u7684\u4E8B\uFF1A\u88C5 sing-box \u2192 \u751F\u6210\u968F\u673A\u7528\u6237\u540D/\u53E3\u4EE4 \u2192 \u8D77\u5E26\u8BA4\u8BC1\u7684 SOCKS5
|
|
7380
|
+
\u2192 \u6CE8\u518C systemd \u670D\u52A1 \u2192 \u6253\u5370\u8FDE\u63A5\u4E32\u3002\u4EC5\u652F\u6301 Debian/Ubuntu/CentOS \u7CFB\u3002
|
|
7381
|
+
|
|
7382
|
+
\u4E3A\u4EC0\u4E48\u9700\u8981\u5B83\uFF1AWorker \u7684\u51FA\u53E3\u662F\u673A\u623F IP\uFF0C\u6D41\u5A92\u4F53\u4E0E\u90E8\u5206\u7AD9\u70B9\u5BF9\u673A\u623F IP
|
|
7383
|
+
\u6709\u7ED3\u6784\u6027\u98CE\u63A7\uFF1B\u6362\u4E00\u4E2A\u81EA\u5DF1\u7684\u51FA\u53E3\u6BD4\u4EFB\u4F55\u300C\u89E3\u9501\u68C0\u6D4B\u300D\u90FD\u6709\u6548\u3002
|
|
7384
|
+
|
|
7385
|
+
\u793A\u4F8B:
|
|
7386
|
+
${NAME} vps --ssh root@203.0.113.10
|
|
7387
|
+
${NAME} vps --print > deploy.sh
|
|
7388
|
+
`;
|
|
7389
|
+
}
|
|
7390
|
+
});
|
|
7391
|
+
|
|
6617
7392
|
// src/cli.ts
|
|
6618
7393
|
init_args();
|
|
6619
7394
|
init_version();
|
|
6620
|
-
var
|
|
7395
|
+
var HELP3 = `
|
|
6621
7396
|
${NAME} v${VERSION}
|
|
6622
7397
|
Cloudflare Pages \u4EE3\u7406\u90E8\u7F72\u4E0E\u4F18\u9009\u5DE5\u5177
|
|
6623
7398
|
|
|
@@ -6625,8 +7400,10 @@ Cloudflare Pages \u4EE3\u7406\u90E8\u7F72\u4E0E\u4F18\u9009\u5DE5\u5177
|
|
|
6625
7400
|
${NAME} \u4EA4\u4E92\u83DC\u5355\uFF08\u63A8\u8350\u9996\u6B21\u4F7F\u7528\uFF09
|
|
6626
7401
|
${NAME} deploy [\u9009\u9879] \u90E8\u7F72 Pages \u53CC\u9879\u76EE
|
|
6627
7402
|
${NAME} scan [\u9009\u9879] \u672C\u5730\u771F\u8FDE\u63A5\u4F18\u9009
|
|
7403
|
+
${NAME} test [\u9009\u9879] \u6D4B\u8BD5\u5355\u4E2A IP \u7684\u5B8C\u6574\u94FE\u8DEF
|
|
6628
7404
|
${NAME} status \u67E5\u770B\u5F53\u524D\u5B9E\u4F8B\u72B6\u6001
|
|
6629
7405
|
${NAME} token [\u9009\u9879] \u68C0\u67E5 API Token \u6743\u9650
|
|
7406
|
+
${NAME} vps [\u9009\u9879] \u5728\u81EA\u5DF1\u7684 VPS \u4E0A\u90E8\u7F72 SOCKS5 \u843D\u5730\u4EE3\u7406
|
|
6630
7407
|
${NAME} config [\u9009\u9879] \u67E5\u770B/\u4FEE\u6539\u672C\u5730\u914D\u7F6E
|
|
6631
7408
|
${NAME} --help \u663E\u793A\u5E2E\u52A9
|
|
6632
7409
|
${NAME} --version \u663E\u793A\u7248\u672C
|
|
@@ -6635,6 +7412,7 @@ Cloudflare Pages \u4EE3\u7406\u90E8\u7F72\u4E0E\u4F18\u9009\u5DE5\u5177
|
|
|
6635
7412
|
${NAME} # \u8FDB\u83DC\u5355\uFF0C\u6309\u63D0\u793A\u64CD\u4F5C
|
|
6636
7413
|
${NAME} deploy --token <TOKEN> # \u76F4\u63A5\u90E8\u7F72
|
|
6637
7414
|
${NAME} scan --host <\u6570\u636E\u9762\u57DF\u540D> # \u76F4\u63A5\u4F18\u9009
|
|
7415
|
+
${NAME} test --host x --ip 104.16.1.1 # \u53EA\u6D4B\u4E00\u4E2A IP
|
|
6638
7416
|
${NAME} scan --host x --panel y --panel-password z # \u4F18\u9009\u5E76\u56DE\u586B
|
|
6639
7417
|
|
|
6640
7418
|
\u6587\u6863: https://github.com/xmwengxing/CFPilot
|
|
@@ -6648,11 +7426,11 @@ async function main() {
|
|
|
6648
7426
|
return;
|
|
6649
7427
|
}
|
|
6650
7428
|
if (!command && (flagBool(args, "h") || flagBool(args, "help"))) {
|
|
6651
|
-
process.stdout.write(
|
|
7429
|
+
process.stdout.write(HELP3);
|
|
6652
7430
|
return;
|
|
6653
7431
|
}
|
|
6654
7432
|
if (command === "help") {
|
|
6655
|
-
process.stdout.write(
|
|
7433
|
+
process.stdout.write(HELP3);
|
|
6656
7434
|
return;
|
|
6657
7435
|
}
|
|
6658
7436
|
switch (command) {
|
|
@@ -6672,6 +7450,11 @@ async function main() {
|
|
|
6672
7450
|
await runScanCommand2(args);
|
|
6673
7451
|
return;
|
|
6674
7452
|
}
|
|
7453
|
+
case "test": {
|
|
7454
|
+
const { runTestCommand: runTestCommand2 } = await Promise.resolve().then(() => (init_single_command(), single_command_exports));
|
|
7455
|
+
await runTestCommand2(args);
|
|
7456
|
+
return;
|
|
7457
|
+
}
|
|
6675
7458
|
case "status": {
|
|
6676
7459
|
const { runStatus: runStatus2 } = await Promise.resolve().then(() => (init_status(), status_exports));
|
|
6677
7460
|
await runStatus2();
|
|
@@ -6687,11 +7470,16 @@ async function main() {
|
|
|
6687
7470
|
await runConfig2(args);
|
|
6688
7471
|
return;
|
|
6689
7472
|
}
|
|
7473
|
+
case "vps": {
|
|
7474
|
+
const { runVpsCommand: runVpsCommand2 } = await Promise.resolve().then(() => (init_command3(), command_exports3));
|
|
7475
|
+
await runVpsCommand2(args);
|
|
7476
|
+
return;
|
|
7477
|
+
}
|
|
6690
7478
|
default: {
|
|
6691
7479
|
process.stderr.write(`\u672A\u77E5\u547D\u4EE4\uFF1A${command}
|
|
6692
7480
|
|
|
6693
7481
|
`);
|
|
6694
|
-
process.stderr.write(
|
|
7482
|
+
process.stderr.write(HELP3);
|
|
6695
7483
|
process.exitCode = 1;
|
|
6696
7484
|
}
|
|
6697
7485
|
}
|