dsh-mobile-plugin 0.5.78 → 0.5.79

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.
@@ -173,6 +173,8 @@ function createControlClient({ state, persist, getPort, getHistoryKey, getAddres
173
173
  function connect() {
174
174
  if (!running || sock) return;
175
175
  if (!state.enabled) return;
176
+ // 用户在面板关掉了「自动上报网络地址」:立刻不连(sync/stop 会把已在连的这条也收掉)。
177
+ if (state.controlReportEnabled === false) return;
176
178
  const addresses = build(state);
177
179
  if (!Array.isArray(addresses) || addresses.length === 0) {
178
180
  connected = false;
@@ -259,7 +261,7 @@ function createControlClient({ state, persist, getPort, getHistoryKey, getAddres
259
261
  tickTimer = setInterval(tick, 60_000);
260
262
  if (tickTimer.unref) tickTimer.unref();
261
263
  }
262
- if (state.enabled && !sock) connect();
264
+ if (state.enabled && state.controlReportEnabled !== false && !sock) connect();
263
265
  return snapshot();
264
266
  }
265
267
 
@@ -277,9 +279,9 @@ function createControlClient({ state, persist, getPort, getHistoryKey, getAddres
277
279
  attempt = 0;
278
280
  }
279
281
 
280
- /** 配置变更后调用:没开 / 没地址 / 没 HK 就停;否则起连或复核。 */
282
+ /** 配置变更后调用:没开 / 用户关了上报 / 没地址 / 没 HK 就停;否则起连或复核。 */
281
283
  function sync() {
282
- if (!state.enabled || build(state).length === 0 || !hk()) {
284
+ if (!state.enabled || state.controlReportEnabled === false || build(state).length === 0 || !hk()) {
283
285
  stop();
284
286
  return;
285
287
  }
package/lib/relay/core.js CHANGED
@@ -56,6 +56,9 @@ function defaultState() {
56
56
  // 老状态文件没这一格时靠这里兜底,别在别处再判一次「没有就拒绝」。
57
57
  pairingTier: 'full',
58
58
  lanEnabled: true, lanPort: 18787, lanSecret: crypto.randomBytes(32).toString('hex'), enabled: false,
59
+ // 是否把本机的网络地址加密上报给「总控」(地址目录)。默认开:这正是本功能一直以来的
60
+ // 行为,做成开关只为了让不想要的人能关掉(关掉后手机换网、手里没新地址就找不回这台电脑)。
61
+ controlReportEnabled: true,
59
62
  // 中转侧 TUNNEL_REGISTER_SECRET 的对偶值。为空时隧道注册会被中转以
60
63
  // close(1008, 'bad registration secret') 拒掉(除非中转根本没开校验)。
61
64
  registerSecret: '',
@@ -123,6 +123,9 @@ function createStatusView(deps) {
123
123
  // 审批自动审阅档(默认关,见 lib/mobile/auto-review.js)。面板与手机设置页都读这一格
124
124
  // 显示开关状态;非 true 一律当关,与 `configOf(state)` 的读法同一口径。
125
125
  approvalAutoReview: state.approvalAutoReview === true,
126
+ // 「自动上报网络地址」(总控上报)开关状态。面板据此显示开关;非 false 一律当开,
127
+ // 与 `configOf(state)` 的读法同一口径(老状态文件没这一格时默认开)。
128
+ controlReportEnabled: state.controlReportEnabled !== false,
126
129
  // 桌面设置页那两颗侧边栏图标的显示开关。**只给桌面客户端读**,手机端不画它们;
127
130
  // 老机器没落过这两格时按开处理,与 configOf 的默认值同一口径。
128
131
  desktopPhoneIcon: state.desktopPhoneIcon !== false,
@@ -577,13 +577,21 @@ function registerControlPlaneRoutes(deps) {
577
577
  // 为什么白名单是「节点公钥」而不是设备 id:隧道那一层只认 WireGuard 公钥,和移动端
578
578
  // 凭据是两套东西 —— 吊销设备凭据并不会把它从隧道白名单里摘掉(见 A3-86)。所以这里
579
579
  // 单独给一个出口,否则「踢一台手机」在隧道这一层无法完成。
580
- // 点对点隧道只有一格里要说的事:这条通道起没起、打通了没有、走的是谁。
581
- // 没有白名单也没有总开关 —— 能连上的前提就是私钥对得上,比白名单更直接;开关那件事
582
- // 交给手机侧的档位(`channelMode`),电脑这边不替人做决定。
580
+ // 点对点隧道只有格里要说的事:这条通道起没起、打通了没有、走的是谁。
581
+ // 助手默认关、用户显式开启才启动(与直连隧道同一口径);走不走这条通道仍由手机侧档位
582
+ // (`channelMode`)决定 —— 这里只管本机这半边准不准它起来。
583
583
  registerRoute({ kind: 'exact', path: '/api/relay/p2p', handler: localOnly('GET', async (_req, res) => {
584
584
  const state = deps.p2p && typeof deps.p2p.status === 'function' ? deps.p2p.status() : null
585
585
  sendJson(res, 200, { ok: true, status: state })
586
586
  }) })
587
+ registerRoute({ kind: 'exact', path: '/api/relay/p2p/enabled', handler: localOnly('POST', async (req, res) => {
588
+ const body = await readJson(req)
589
+ if (deps.p2p && typeof deps.p2p.setEnabled === 'function') {
590
+ deps.p2p.setEnabled(Boolean(body && body.enabled))
591
+ }
592
+ const state = deps.p2p && typeof deps.p2p.status === 'function' ? deps.p2p.status() : null
593
+ sendJson(res, 200, { ok: true, status: state })
594
+ }) })
587
595
 
588
596
  // ── FRP 直连:导入配置 → 落盘并拉起本地 frpc ───────────────────────────────
589
597
  //
@@ -988,6 +996,9 @@ function registerControlPlaneRoutes(deps) {
988
996
  // 审批自动审阅档(默认关)。只认布尔值,别的形状一律当没带 —— 这一个是安全开关,
989
997
  // 把 'false' / 0 静默解释成 false 会让「我明明关掉了」变成一句不可查的话。
990
998
  if (typeof body?.approvalAutoReview === 'boolean') patch.approvalAutoReview = body.approvalAutoReview
999
+ // 「自动上报网络地址」(总控上报)开关。只认布尔值,别的形状当没带 —— 'false' / 0 静默
1000
+ // 解释成关会让用户以为是自己关的,而界面上再也没处改回来。
1001
+ if (typeof body?.controlReportEnabled === 'boolean') patch.controlReportEnabled = body.controlReportEnabled
991
1002
  // 桌面侧边栏那两颗图标的显示开关。非布尔值当没带:'false' / 0 静默解释成隐藏,
992
1003
  // 用户会以为是自己关的,而界面上再也找不到那颗图标去改回来。
993
1004
  if (typeof body?.desktopPhoneIcon === 'boolean') patch.desktopPhoneIcon = body.desktopPhoneIcon
@@ -1340,8 +1351,9 @@ const WEB_ACCESS_ROUTES = new Set([
1340
1351
  // 但仍留在窗口白名单里保持「路由都在白名单」这条语义统一。
1341
1352
  '/api/relay/frp/import',
1342
1353
  '/api/relay/frp/stop',
1343
- // 点对点隧道的现状(只有查看,没有开关也没有白名单:能连上的前提就是密钥对得上)。
1354
+ // 点对点隧道的现状与启停(没有白名单:能连上的前提就是密钥对得上)。
1344
1355
  '/api/relay/p2p',
1356
+ '/api/relay/p2p/enabled',
1345
1357
  '/api/relay/revoke-all',
1346
1358
  '/api/relay/config',
1347
1359
  '/api/relay/check-port',
@@ -1382,6 +1394,7 @@ const LOCAL_OPERATOR_ROUTES = new Set([
1382
1394
  '/api/relay/devices/permissions',
1383
1395
  '/api/relay/tailcat/enabled',
1384
1396
  '/api/relay/tailcat/revoke',
1397
+ '/api/relay/p2p/enabled',
1385
1398
  // FRP 直连的启停:会拉起/杀掉本机进程,属于只允许本机或局域网直连的动作。
1386
1399
  '/api/relay/frp/import',
1387
1400
  '/api/relay/frp/stop',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-mobile-plugin",
3
- "version": "0.5.78",
3
+ "version": "0.5.79",
4
4
  "description": "Mobile API (/api/mobile/v1) and relay client for the DSH mobile app — desktop profile build (dsh 0.2.x, peers resolved by the host)",
5
5
  "license": "MIT",
6
6
  "icon": "./icon.png",