@qpjoy/tunnel-cli 0.1.7 → 0.1.8

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.
Files changed (2) hide show
  1. package/dist/hdo.js +10 -5
  2. package/package.json +2 -2
package/dist/hdo.js CHANGED
@@ -152,7 +152,9 @@ async function enrollCommand(args, refreshOnly) {
152
152
  const manifest = await apiJson(serverUrl, auth.accessToken, `/api/v1/hdo/manifest/${encodeURIComponent(deviceId)}`, {
153
153
  method: 'GET',
154
154
  });
155
- const runtime = hdoRuntimeFromManifest(manifest, registered, keys.privateKey);
155
+ const runtime = hdoRuntimeFromManifest(manifest, registered, keys.privateKey, {
156
+ allowEndpointlessDirectPeers: direct.directListener,
157
+ });
156
158
  writeWireGuardConfig(configPath, (0, electron_core_wireguard_1.renderHdoClientWireGuardConfig)({
157
159
  privateKey: runtime.privateKey,
158
160
  address: runtime.address,
@@ -537,7 +539,7 @@ function resolveDirectEndpoint(options, previous) {
537
539
  endpoint: endpointHost && listenPort ? `${endpointHost}:${listenPort}` : undefined,
538
540
  };
539
541
  }
540
- function directPeersFromManifest(wireGuard, ownOverlayIp) {
542
+ function directPeersFromManifest(wireGuard, ownOverlayIp, options = {}) {
541
543
  const ownIp = ownOverlayIp.split('/')[0] || ownOverlayIp;
542
544
  const rows = Array.isArray(wireGuard.directPeers) ? wireGuard.directPeers : [];
543
545
  return rows.flatMap((item) => {
@@ -549,11 +551,14 @@ function directPeersFromManifest(wireGuard, ownOverlayIp) {
549
551
  if (!publicKey || !overlayIp || overlayIp === ownIp)
550
552
  return [];
551
553
  const allowedIps = stringArray(row.allowedIps);
554
+ const endpoint = stringField(row.endpoint);
555
+ if (!endpoint && options.allowEndpointlessDirectPeers !== true)
556
+ return [];
552
557
  const peer = {
553
558
  name: `HDO Direct ${stringField(row.label) ?? stringField(row.id) ?? overlayIp}`,
554
559
  publicKey,
555
560
  allowedIps: allowedIps.length ? allowedIps : [`${overlayIp}/32`],
556
- endpoint: stringField(row.endpoint),
561
+ endpoint,
557
562
  persistentKeepalive: 25,
558
563
  };
559
564
  return [peer];
@@ -611,7 +616,7 @@ function writeWireGuardConfig(path, content) {
611
616
  (0, node_fs_1.writeFileSync)(path, content, { mode: 0o600 });
612
617
  chmodSyncSafe(path, 0o600);
613
618
  }
614
- function hdoRuntimeFromManifest(manifest, registered, privateKey) {
619
+ function hdoRuntimeFromManifest(manifest, registered, privateKey, options = {}) {
615
620
  const root = requireRecord(manifest, 'manifest');
616
621
  const license = requireRecord(root.license, 'manifest.license');
617
622
  if (license.active !== true) {
@@ -645,7 +650,7 @@ function hdoRuntimeFromManifest(manifest, registered, privateKey) {
645
650
  domesticPublicKey,
646
651
  domesticEndpoint,
647
652
  allowedIps,
648
- directPeers: directPeersFromManifest(wireGuard, overlayIp),
653
+ directPeers: directPeersFromManifest(wireGuard, overlayIp, options),
649
654
  generation: numberField(root.generation),
650
655
  };
651
656
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qpjoy/tunnel-cli",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Global QPJoy Tunnel CLI for mihomo-client and cross-platform HDO mesh enrollment.",
5
5
  "private": false,
6
6
  "type": "commonjs",
@@ -22,7 +22,7 @@
22
22
  "access": "public"
23
23
  },
24
24
  "dependencies": {
25
- "@qpjoy/electron-core-wireguard": "^0.1.19"
25
+ "@qpjoy/electron-core-wireguard": "^0.1.21"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/node": "^22.10.7"