cfpilot 0.33.6 → 0.40.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/dist/cli.js CHANGED
@@ -87,11 +87,35 @@ var VERSION, NAME;
87
87
  var init_version = __esm({
88
88
  "src/shared/version.ts"() {
89
89
  "use strict";
90
- VERSION = "0.33.6";
90
+ VERSION = "0.40.0";
91
91
  NAME = "cfpilot";
92
92
  }
93
93
  });
94
94
 
95
+ // src/shared/proxy.ts
96
+ function enableEnvProxy() {
97
+ if (process.env.NODE_USE_ENV_PROXY === "0") return false;
98
+ const hasProxyVar = ["HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy"].some(
99
+ (key) => (process.env[key] ?? "").trim() !== ""
100
+ );
101
+ if (!hasProxyVar) return false;
102
+ if (process.env.NODE_USE_ENV_PROXY === "1") return true;
103
+ process.env.NODE_USE_ENV_PROXY = "1";
104
+ return true;
105
+ }
106
+ function describeProxy() {
107
+ for (const key of ["HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy"]) {
108
+ const raw = (process.env[key] ?? "").trim();
109
+ if (raw) return `${key} ${raw}`;
110
+ }
111
+ return "\u76F4\u8FDE";
112
+ }
113
+ var init_proxy = __esm({
114
+ "src/shared/proxy.ts"() {
115
+ "use strict";
116
+ }
117
+ });
118
+
95
119
  // src/menu/ui.ts
96
120
  function wrap(open2, close) {
97
121
  return (s) => useColor ? `\x1B[${open2}m${s}\x1B[${close}m` : s;
@@ -1812,11 +1836,18 @@ function versionFromTag(tag) {
1812
1836
  for (const prefix of ["desktop-v", "gui-v", "v"]) {
1813
1837
  if (text2.startsWith(prefix)) {
1814
1838
  const rest = text2.slice(prefix.length);
1815
- return /^\d+\.\d+\.\d+/.test(rest) ? rest : "";
1839
+ const m = /^(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?)$/.exec(rest);
1840
+ return m ? m[1] : "";
1816
1841
  }
1817
1842
  }
1818
1843
  return "";
1819
1844
  }
1845
+ function isSafeReleaseTag(tag) {
1846
+ return /^(?:desktop-v|gui-v|v)\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(tag);
1847
+ }
1848
+ function officialAssetUrl(tag, assetName) {
1849
+ return `${RELEASES_WEB}/download/${tag}/${assetName}`;
1850
+ }
1820
1851
  async function fetchRemoteKernelInfo(options = {}) {
1821
1852
  if (isRemoteDisabled()) return null;
1822
1853
  const releases = await fetchReleasesWithFallback(options.timeoutMs ?? DEFAULT_TIMEOUT_MS);
@@ -1825,13 +1856,18 @@ async function fetchRemoteKernelInfo(options = {}) {
1825
1856
  }
1826
1857
  const sorted = releases.filter((release) => !release.draft && !release.prerelease).map((release) => ({ release, version: versionFromTag(release.tag_name) })).filter((item) => item.version !== "").sort((a, b) => compareSemver(b.version, a.version));
1827
1858
  for (const item of sorted) {
1828
- const controlUrl = findAssetUrl(item.release.assets ?? [], CONTROL_ASSET_NAME);
1829
- const dataUrl = findAssetUrl(item.release.assets ?? [], DATA_ASSET_NAME);
1830
- const checksumsUrl = findAssetUrl(item.release.assets ?? [], CHECKSUMS_ASSET_NAME);
1831
- if (!controlUrl || !dataUrl) {
1859
+ const assets = item.release.assets ?? [];
1860
+ if (!hasAsset(assets, CONTROL_ASSET_NAME) || !hasAsset(assets, DATA_ASSET_NAME)) {
1832
1861
  continue;
1833
1862
  }
1834
- return { version: item.version, controlUrl, dataUrl, checksumsUrl };
1863
+ const tag = item.release.tag_name.trim();
1864
+ if (!isSafeReleaseTag(tag)) continue;
1865
+ return {
1866
+ version: item.version,
1867
+ controlUrl: officialAssetUrl(tag, CONTROL_ASSET_NAME),
1868
+ dataUrl: officialAssetUrl(tag, DATA_ASSET_NAME),
1869
+ checksumsUrl: officialAssetUrl(tag, CHECKSUMS_ASSET_NAME)
1870
+ };
1835
1871
  }
1836
1872
  return null;
1837
1873
  }
@@ -1873,12 +1909,9 @@ async function fetchReleasesWithFallback(timeoutMs) {
1873
1909
  };
1874
1910
  return [pseudo];
1875
1911
  }
1876
- function findAssetUrl(assets, name) {
1912
+ function hasAsset(assets, name) {
1877
1913
  const want = name.trim().toLowerCase();
1878
- for (const asset of assets) {
1879
- if (asset.name.trim().toLowerCase() === want) return asset.browser_download_url;
1880
- }
1881
- return "";
1914
+ return assets.some((asset) => asset.name.trim().toLowerCase() === want);
1882
1915
  }
1883
1916
  function isRemoteDisabled() {
1884
1917
  const raw = process.env[REMOTE_OFF_ENV]?.trim().toLowerCase();
@@ -2071,8 +2104,10 @@ async function loadKernelBundle(currentVersion, options = {}) {
2071
2104
  };
2072
2105
  } catch (err) {
2073
2106
  log(
2074
- `\xB7 \u8FDC\u7A0B\u5185\u6838 ${remote.version} \u83B7\u53D6\u5931\u8D25\uFF0C\u6539\u7528\u5185\u7F6E\u5185\u6838\uFF1A` + (err instanceof Error ? err.message : String(err))
2107
+ `\xB7 \u8FDC\u7A0B\u5185\u6838 ${remote.version} \u83B7\u53D6\u5931\u8D25\uFF0C\u6539\u7528\u5185\u7F6E\u5185\u6838 ${currentVersion}\uFF08\u90E8\u7F72\u7167\u5E38\u8FDB\u884C\uFF09\uFF1A` + (err instanceof Error ? err.message : String(err))
2075
2108
  );
2109
+ log(` \u2192 \u5185\u7F6E\u5185\u6838\u4E0E\u5F53\u524D\u7248\u672C\u4E00\u81F4\uFF0C\u529F\u80FD\u5B8C\u6574\uFF1B\u5F53\u524D\u8BBF\u95EE\u65B9\u5F0F\uFF1A${describeProxy()}`);
2110
+ log(" \u2192 \u60F3\u8981\u66F4\u65B0\u7684\u5185\u6838\u8BF7\u8BBE\u7F6E HTTPS_PROXY \u540E\u91CD\u8BD5");
2076
2111
  }
2077
2112
  }
2078
2113
  const control = await loadBuiltinBundle("control.js");
@@ -2088,15 +2123,7 @@ async function fetchRemoteKernel(info, timeoutMs) {
2088
2123
  const dir = cacheDir(info.version);
2089
2124
  const controlPath = join2(dir, "control.js");
2090
2125
  const dataPath = join2(dir, "dataplane.js");
2091
- const sumsPath = join2(dir, "SHA256SUMS");
2092
- let sumsText = await readCached(sumsPath);
2093
- let sums = sumsText ? parseChecksums(sumsText) : null;
2094
- const sumsComplete = sums !== null && sums.has(CONTROL_ASSET_NAME.toLowerCase()) && sums.has(DATA_ASSET_NAME.toLowerCase());
2095
- if (!sums || !sumsComplete) {
2096
- const fetched = await downloadChecksums(info, timeoutMs);
2097
- sumsText = fetched.text;
2098
- sums = fetched.map;
2099
- }
2126
+ const { map: sums } = await downloadChecksums(info, timeoutMs);
2100
2127
  let control = await readCached(controlPath);
2101
2128
  let data = await readCached(dataPath);
2102
2129
  if (control) {
@@ -2122,7 +2149,6 @@ async function fetchRemoteKernel(info, timeoutMs) {
2122
2149
  verifyAsset("dataplane.js", data, sums);
2123
2150
  if (!control.trim()) throw new Error("\u4E0B\u8F7D\u5230\u7684\u63A7\u5236\u9762\u4EA7\u7269\u4E3A\u7A7A");
2124
2151
  if (!data.trim()) throw new Error("\u4E0B\u8F7D\u5230\u7684\u6570\u636E\u9762\u4EA7\u7269\u4E3A\u7A7A");
2125
- await writeCached(sumsPath, sumsText).catch(() => void 0);
2126
2152
  await writeCached(controlPath, control).catch(() => void 0);
2127
2153
  await writeCached(dataPath, data).catch(() => void 0);
2128
2154
  return { control, data };
@@ -2132,6 +2158,7 @@ var init_kernel_remote = __esm({
2132
2158
  "src/deploy/kernel-remote.ts"() {
2133
2159
  "use strict";
2134
2160
  init_version_util();
2161
+ init_proxy();
2135
2162
  init_github_mirrors();
2136
2163
  CONTROL_ASSET_NAME = "cfpilot-kernel-control.js";
2137
2164
  DATA_ASSET_NAME = "cfpilot-kernel-dataplane.js";
@@ -2508,7 +2535,8 @@ async function deployPagesSplit(options) {
2508
2535
  const result = {
2509
2536
  control: { name: options.controlProject, subdomain: "" },
2510
2537
  data: { name: options.dataProject, subdomain: "" },
2511
- warnings
2538
+ warnings,
2539
+ success: true
2512
2540
  };
2513
2541
  const kv = { KV: { namespace_id: options.kvNamespaceId } };
2514
2542
  const kernel = await resolveKernel(options, log, warnings);
@@ -2758,6 +2786,7 @@ async function deployPagesSplit(options) {
2758
2786
  });
2759
2787
  if (!dataAttempt) {
2760
2788
  warnings.push("\u6570\u636E\u9762\u90E8\u7F72\u5931\u8D25\uFF0C\u5DF2\u4E2D\u6B62\u672C\u6B21\u90E8\u7F72\uFF08\u63A7\u5236\u9762\u4E0D\u518D\u90E8\u7F72\uFF09\u3002");
2789
+ result.success = false;
2761
2790
  return result;
2762
2791
  }
2763
2792
  {
@@ -2820,8 +2849,10 @@ async function deployPagesSplit(options) {
2820
2849
  if (controlAttempt) {
2821
2850
  result.control.name = controlAttempt.project ?? controlName;
2822
2851
  result.control.subdomain = controlAttempt.subdomain;
2852
+ } else {
2853
+ result.success = false;
2823
2854
  }
2824
- if (result.control.subdomain && result.data.subdomain) {
2855
+ if (result.success !== false && result.control.subdomain && result.data.subdomain) {
2825
2856
  const build = effectiveBuild;
2826
2857
  const kernelVersion = kernel.version.trim();
2827
2858
  await writeManifest(client, options.accountId, options.kvNamespaceId, {
@@ -2941,7 +2972,7 @@ async function deployOnce(params) {
2941
2972
  return { project: name, subdomain: slot.subdomain, deploymentId: deployment.id };
2942
2973
  }
2943
2974
  warnings.push(`${label}\u90E8\u7F72\u672A\u786E\u8BA4\u6210\u529F\uFF08\u9879\u76EE ${name}\uFF0C\u72B6\u6001\uFF1A${final?.latest_stage?.status ?? "\u672A\u77E5"}\uFF09`);
2944
- return { project: name, subdomain: slot.subdomain, deploymentId: deployment.id };
2975
+ return null;
2945
2976
  } catch (err) {
2946
2977
  const message = err instanceof Error ? err.message : String(err);
2947
2978
  const blocked = /8000119|has been blocked/i.test(message);
@@ -3323,9 +3354,11 @@ async function runDeployCommand(args) {
3323
3354
  process.stdout.write(`
3324
3355
  ${"\u2500".repeat(52)}
3325
3356
  `);
3326
- process.stdout.write(`\u63A7\u5236\u9762\uFF1Ahttps://${result.control.subdomain}${result.panelPath ?? ""}
3357
+ if (result.control.subdomain) {
3358
+ process.stdout.write(`\u63A7\u5236\u9762\uFF1Ahttps://${result.control.subdomain}${result.panelPath ?? ""}
3327
3359
  `);
3328
- process.stdout.write(`\u6570\u636E\u9762\uFF1Ahttps://${result.data.subdomain}
3360
+ }
3361
+ if (result.data.subdomain) process.stdout.write(`\u6570\u636E\u9762\uFF1Ahttps://${result.data.subdomain}
3329
3362
  `);
3330
3363
  if (result.uuid) process.stdout.write(`UUID\uFF1A${result.uuid}
3331
3364
  `);
@@ -3333,8 +3366,15 @@ ${"\u2500".repeat(52)}
3333
3366
  `);
3334
3367
  if (result.panelPassword) process.stdout.write(`\u9762\u677F\u5BC6\u7801\uFF1A${result.panelPassword}
3335
3368
  `);
3336
- process.stdout.write(`\u2705 \u90E8\u7F72\u6210\u529F
3369
+ const deploySucceeded = result.success !== false;
3370
+ if (deploySucceeded) {
3371
+ process.stdout.write(`\u2705 \u90E8\u7F72\u6210\u529F
3372
+ `);
3373
+ } else {
3374
+ process.exitCode = 1;
3375
+ process.stdout.write(`\u274C \u90E8\u7F72\u672A\u5B8C\u6210
3337
3376
  `);
3377
+ }
3338
3378
  if (result.warnings.length > 0) {
3339
3379
  process.stdout.write(`
3340
3380
  \u544A\u8B66\uFF08${result.warnings.length} \u6761\uFF09\uFF1A
@@ -4105,11 +4145,13 @@ function measureThroughput(options) {
4105
4145
  let lastError = "";
4106
4146
  let headerMismatch = false;
4107
4147
  const sockets = [];
4148
+ const staggerTimers = [];
4108
4149
  const finish = () => {
4109
4150
  if (settled) return;
4110
4151
  settled = true;
4111
4152
  clearInterval(ticker);
4112
4153
  clearTimeout(timer);
4154
+ for (const handle of staggerTimers) clearTimeout(handle);
4113
4155
  for (const s of sockets) {
4114
4156
  try {
4115
4157
  s.destroy();
@@ -4149,6 +4191,7 @@ function measureThroughput(options) {
4149
4191
  ""
4150
4192
  ].join("\r\n");
4151
4193
  const openOne = () => {
4194
+ if (settled) return;
4152
4195
  let headerDone = false;
4153
4196
  let headerBuffer = Buffer.alloc(0);
4154
4197
  const socket = tls.connect(
@@ -4220,7 +4263,8 @@ function measureThroughput(options) {
4220
4263
  }, windowMs);
4221
4264
  const timer = setTimeout(finish, durationMs + 4e3);
4222
4265
  for (let i = 0; i < connCount; i++) {
4223
- setTimeout(openOne, i * 60);
4266
+ const handle = setTimeout(openOne, i * 60);
4267
+ staggerTimers.push(handle);
4224
4268
  }
4225
4269
  });
4226
4270
  }
@@ -4655,6 +4699,27 @@ var init_true_probe = __esm({
4655
4699
  }
4656
4700
  });
4657
4701
 
4702
+ // src/scan/pool.ts
4703
+ async function pool(items, concurrency, worker, shouldStop) {
4704
+ const slots = new Array(items.length);
4705
+ let cursor = 0;
4706
+ const runners = Array.from({ length: Math.max(1, Math.min(concurrency, items.length)) }, async () => {
4707
+ for (; ; ) {
4708
+ if (shouldStop?.()) return;
4709
+ const index = cursor++;
4710
+ if (index >= items.length) return;
4711
+ slots[index] = await worker(items[index], index);
4712
+ }
4713
+ });
4714
+ await Promise.all(runners);
4715
+ return slots.filter((r) => r !== void 0);
4716
+ }
4717
+ var init_pool = __esm({
4718
+ "src/scan/pool.ts"() {
4719
+ "use strict";
4720
+ }
4721
+ });
4722
+
4658
4723
  // src/scan/speed-url.ts
4659
4724
  import * as tls2 from "node:tls";
4660
4725
  import * as net from "node:net";
@@ -5440,20 +5505,6 @@ async function tcpPing(ip, port, timeoutMs) {
5440
5505
  socket.connect(port, ip);
5441
5506
  });
5442
5507
  }
5443
- async function pool(items, concurrency, worker, shouldStop) {
5444
- const out2 = new Array(items.length);
5445
- let cursor = 0;
5446
- const runners = Array.from({ length: Math.max(1, Math.min(concurrency, items.length)) }, async () => {
5447
- for (; ; ) {
5448
- if (shouldStop?.()) return;
5449
- const index = cursor++;
5450
- if (index >= items.length) return;
5451
- out2[index] = await worker(items[index], index);
5452
- }
5453
- });
5454
- await Promise.all(runners);
5455
- return out2;
5456
- }
5457
5508
  async function poolAdaptive(items, concurrency, worker, batchSize = 200) {
5458
5509
  const out2 = [];
5459
5510
  const maxConcurrency = Math.max(1, concurrency);
@@ -5642,6 +5693,15 @@ async function runScan(options) {
5642
5693
  countFailure(failures, "ws101", item.probe?.error);
5643
5694
  }
5644
5695
  wsPool = wsFiltered2;
5696
+ if (stoppedEarly) {
5697
+ report({
5698
+ type: "progress",
5699
+ stage: 2,
5700
+ done: probeDone,
5701
+ total: stage1.length,
5702
+ message: `\u5DF2\u51D1\u591F ${earlyExitTarget} \u4E2A\u76EE\u6807\u56FD\u5BB6\u7684\u53EF\u7528\u8282\u70B9\uFF0C\u63D0\u524D\u6536\u5DE5\uFF08\u53EA\u6D4B\u4E86 ${probeDone}/${stage1.length}\uFF0C\u5176\u4F59\u672A\u6D4B\uFF09`
5703
+ });
5704
+ }
5645
5705
  }
5646
5706
  let xhttpOk = wsPool;
5647
5707
  let xhttpOkCount = 0;
@@ -6119,6 +6179,7 @@ var init_scan = __esm({
6119
6179
  "src/scan/scan.ts"() {
6120
6180
  "use strict";
6121
6181
  init_true_probe();
6182
+ init_pool();
6122
6183
  init_speed_url();
6123
6184
  init_countries();
6124
6185
  init_unlock();
@@ -6161,11 +6222,13 @@ async function postResults(callbackUrl, token, entries, mode = "replace", timeou
6161
6222
  "User-Agent": "CFPilot-Scanner/1.0"
6162
6223
  },
6163
6224
  body: JSON.stringify({ ips: entries, mode }),
6164
- signal: AbortSignal.timeout(timeoutMs)
6225
+ signal: AbortSignal.timeout(timeoutMs),
6226
+ // callback 来自本地桥接请求,禁止自动跟随到内网或其它主机,
6227
+ // 避免把 Bearer 令牌转发给重定向目标。
6228
+ redirect: "manual"
6165
6229
  });
6166
6230
  if (!response.ok) {
6167
- const text2 = await response.text().catch(() => "");
6168
- return { ok: false, status: response.status, error: `\u56DE\u4F20\u5931\u8D25 HTTP ${response.status} ${text2}`.trim() };
6231
+ return { ok: false, status: response.status, error: `\u56DE\u4F20\u5931\u8D25 HTTP ${response.status}` };
6169
6232
  }
6170
6233
  return { ok: true, status: response.status };
6171
6234
  } catch (err) {
@@ -7351,6 +7414,7 @@ __export(server_exports, {
7351
7414
  validateCallbackUrl: () => validateCallbackUrl
7352
7415
  });
7353
7416
  import { createServer } from "node:http";
7417
+ import { randomBytes as randomBytes4 } from "node:crypto";
7354
7418
  function normalizeSample(value) {
7355
7419
  if (typeof value === "number" && Number.isFinite(value) && value > 0) {
7356
7420
  return Math.min(Math.floor(value), DEFAULT_CANDIDATE_SAMPLE);
@@ -7440,8 +7504,18 @@ function sendJson(res, status2, data) {
7440
7504
  res.end(body);
7441
7505
  }
7442
7506
  async function readBody(req) {
7507
+ const declared = Number(req.headers["content-length"] ?? 0);
7508
+ if (Number.isFinite(declared) && declared > MAX_BRIDGE_BODY_BYTES) {
7509
+ throw new Error("\u8BF7\u6C42\u4F53\u8D85\u8FC7 2MiB \u4E0A\u9650");
7510
+ }
7443
7511
  const chunks = [];
7444
- for await (const chunk of req) chunks.push(chunk);
7512
+ let total = 0;
7513
+ for await (const chunk of req) {
7514
+ const part = chunk;
7515
+ total += part.byteLength;
7516
+ if (total > MAX_BRIDGE_BODY_BYTES) throw new Error("\u8BF7\u6C42\u4F53\u8D85\u8FC7 2MiB \u4E0A\u9650");
7517
+ chunks.push(part);
7518
+ }
7445
7519
  return Buffer.concat(chunks).toString("utf8");
7446
7520
  }
7447
7521
  function parseStartScanRequest(text2) {
@@ -7503,8 +7577,9 @@ function broadcast(job, event) {
7503
7577
  function startBridge(options = {}) {
7504
7578
  const host = options.host ?? "127.0.0.1";
7505
7579
  const port = options.port ?? DEFAULT_BRIDGE_PORT;
7580
+ const token = randomBytes4(24).toString("hex");
7506
7581
  const server = createServer((req, res) => {
7507
- void handleRequest(req, res).catch((err) => {
7582
+ void handleRequest(req, res, token).catch((err) => {
7508
7583
  sendJson(res, 500, { ok: false, error: err instanceof Error ? err.message : String(err) });
7509
7584
  });
7510
7585
  });
@@ -7516,6 +7591,7 @@ function startBridge(options = {}) {
7516
7591
  resolve4({
7517
7592
  server,
7518
7593
  port: boundPort,
7594
+ token,
7519
7595
  close: () => new Promise((done) => {
7520
7596
  for (const job of jobs.values()) {
7521
7597
  for (const subscriber of job.subscribers) subscriber.end();
@@ -7527,8 +7603,12 @@ function startBridge(options = {}) {
7527
7603
  });
7528
7604
  });
7529
7605
  }
7530
- async function handleRequest(req, res) {
7606
+ async function handleRequest(req, res, bridgeToken) {
7531
7607
  const url = new URL(req.url ?? "/", `http://${req.headers.host ?? "127.0.0.1"}`);
7608
+ if (req.headers[BRIDGE_TOKEN_HEADER] !== bridgeToken) {
7609
+ sendJson(res, 401, { ok: false, error: "\u6865\u63A5\u670D\u52A1\u672A\u6388\u6743" });
7610
+ return;
7611
+ }
7532
7612
  if (req.method === "OPTIONS") {
7533
7613
  res.writeHead(204, corsHeaders());
7534
7614
  res.end();
@@ -7682,7 +7762,7 @@ async function handleRequest(req, res) {
7682
7762
  }
7683
7763
  sendJson(res, 404, { ok: false, error: "\u63A5\u53E3\u4E0D\u5B58\u5728" });
7684
7764
  }
7685
- var BRIDGE_VERSION, DEFAULT_BRIDGE_PORT, jobs, jobCounter, JOB_TTL_MS, MAX_JOBS;
7765
+ var BRIDGE_VERSION, DEFAULT_BRIDGE_PORT, jobs, jobCounter, JOB_TTL_MS, MAX_JOBS, MAX_BRIDGE_BODY_BYTES, BRIDGE_TOKEN_HEADER;
7686
7766
  var init_server = __esm({
7687
7767
  "src/scan/server.ts"() {
7688
7768
  "use strict";
@@ -7695,6 +7775,8 @@ var init_server = __esm({
7695
7775
  jobCounter = 0;
7696
7776
  JOB_TTL_MS = 10 * 60 * 1e3;
7697
7777
  MAX_JOBS = 5;
7778
+ MAX_BRIDGE_BODY_BYTES = 2 * 1024 * 1024;
7779
+ BRIDGE_TOKEN_HEADER = "x-cfpilot-bridge-token";
7698
7780
  }
7699
7781
  });
7700
7782
 
@@ -8237,7 +8319,7 @@ function upsertCandidates(pool2, inputs, now = Date.now(), maxCandidates = POOL_
8237
8319
  return result;
8238
8320
  }
8239
8321
  var POOL_SCHEMA, POOL_FILENAME, ENTRY_IP, POOL_EXPIRE_MS, POOL_MAX_CANDIDATES, LOCK_STALE_MS, LOCK_TIMEOUT_MS, LOCK_RETRY_MS, V4_NETS, V6_NETS, sleep;
8240
- var init_pool = __esm({
8322
+ var init_pool2 = __esm({
8241
8323
  "src/sources/pool.ts"() {
8242
8324
  "use strict";
8243
8325
  init_ip_ranges();
@@ -8376,7 +8458,7 @@ var init_sample = __esm({
8376
8458
  "src/sources/sample.ts"() {
8377
8459
  "use strict";
8378
8460
  init_ip_ranges();
8379
- init_pool();
8461
+ init_pool2();
8380
8462
  POOL_SAMPLE_LIMIT = 200;
8381
8463
  }
8382
8464
  });
@@ -9464,7 +9546,8 @@ async function runScanCommand(args) {
9464
9546
  ` ${NAME} \u672C\u5730\u6865\u63A5\u670D\u52A1\u5DF2\u542F\u52A8`,
9465
9547
  ` \u76D1\u542C\u5730\u5740\uFF1Ahttp://${host2}:${handle.port}`,
9466
9548
  ` \u7248\u672C\uFF1Av${BRIDGE_VERSION2}`,
9467
- " \u53EF\u7528 HTTP \u63A5\u53E3\uFF1AGET /status\u3001POST /start-scan\u3001GET /events\u3001GET /results",
9549
+ ` \u6865\u63A5\u4EE4\u724C\uFF1A${handle.token}`,
9550
+ " \u53EF\u7528 HTTP \u63A5\u53E3\uFF1AGET /status\u3001POST /start-scan\u3001GET /events\u3001GET /results\uFF08\u8BF7\u6C42\u5934 x-cfpilot-bridge-token\uFF09",
9468
9551
  " \u6309 Ctrl+C \u9000\u51FA\u3002",
9469
9552
  ""
9470
9553
  ].join("\n")
@@ -9875,7 +9958,7 @@ var init_command2 = __esm({
9875
9958
  init_help2();
9876
9959
  init_speed_url();
9877
9960
  init_ip_ranges();
9878
- init_pool();
9961
+ init_pool2();
9879
9962
  init_sample();
9880
9963
  adaptiveContexts = /* @__PURE__ */ new WeakMap();
9881
9964
  poolSamples = /* @__PURE__ */ new WeakMap();
@@ -10752,7 +10835,7 @@ var init_config2 = __esm({
10752
10835
  "src/sources/config.ts"() {
10753
10836
  "use strict";
10754
10837
  init_builtin_generated();
10755
- init_pool();
10838
+ init_pool2();
10756
10839
  SOURCES_SCHEMA = 2;
10757
10840
  SOURCES_SCHEMA_V1 = 1;
10758
10841
  SOURCES_FILENAME = "external-sources.json";
@@ -11043,7 +11126,7 @@ var init_providers = __esm({
11043
11126
  "src/sources/providers.ts"() {
11044
11127
  "use strict";
11045
11128
  init_fetch();
11046
- init_pool();
11129
+ init_pool2();
11047
11130
  API_SOURCE_TYPES = ["ripe-stat"];
11048
11131
  PROVIDERS = {
11049
11132
  "ripe-stat": {
@@ -11418,7 +11501,7 @@ var init_manager = __esm({
11418
11501
  init_fetch();
11419
11502
  init_normalizer();
11420
11503
  init_providers();
11421
- init_pool();
11504
+ init_pool2();
11422
11505
  }
11423
11506
  });
11424
11507
 
@@ -11517,7 +11600,7 @@ var init_light = __esm({
11517
11600
  "use strict";
11518
11601
  init_store();
11519
11602
  init_true_probe();
11520
- init_pool();
11603
+ init_pool2();
11521
11604
  LIGHT_MAX_PER_SYNC = 100;
11522
11605
  LIGHT_CONCURRENCY = 8;
11523
11606
  LIGHT_CONNECT_TIMEOUT_MS = 2e3;
@@ -11725,7 +11808,7 @@ var init_command3 = __esm({
11725
11808
  init_fetch();
11726
11809
  init_providers();
11727
11810
  init_manager();
11728
- init_pool();
11811
+ init_pool2();
11729
11812
  HELP = `
11730
11813
  cfpilot source <\u52A8\u4F5C> [\u9009\u9879] \u5916\u90E8 IP \u6570\u636E\u6E90\u7BA1\u7406\uFF08\u672C\u5730\u6C60\uFF0C\u4E0D\u5199 KV\uFF09
11731
11814
 
@@ -12715,6 +12798,7 @@ ${NAME} vps \u2014\u2014 \u5728\u81EA\u5DF1\u7684 VPS \u4E0A\u90E8\u7F72 SOCKS5
12715
12798
  // src/cli.ts
12716
12799
  init_args();
12717
12800
  init_version();
12801
+ init_proxy();
12718
12802
  var HELP6 = `
12719
12803
  ${NAME} v${VERSION}
12720
12804
  Cloudflare Pages \u4EE3\u7406\u90E8\u7F72\u4E0E\u4F18\u9009\u5DE5\u5177
@@ -12744,6 +12828,7 @@ Cloudflare Pages \u4EE3\u7406\u90E8\u7F72\u4E0E\u4F18\u9009\u5DE5\u5177
12744
12828
  \u6587\u6863: https://github.com/xmwengxing/CFPilot
12745
12829
  `;
12746
12830
  async function main() {
12831
+ enableEnvProxy();
12747
12832
  const args = parseArgs(process.argv.slice(2));
12748
12833
  const command = args.command;
12749
12834
  if (flagBool(args, "v") || flagBool(args, "version") || command === "version") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cfpilot",
3
- "version": "0.33.6",
3
+ "version": "0.40.0",
4
4
  "description": "CFPilot —— Cloudflare Pages 代理部署与优选工具(交互菜单 + 子命令)",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0-only",