dsh-mobile-plugin 0.1.66 → 0.1.67

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/lib/impl.js CHANGED
@@ -24,7 +24,7 @@ const { authorized } = require('./mobile/auth.js')
24
24
  const { createSidecarLifecycle } = require('./sidecar-lifecycle.cjs')
25
25
  const { createMirrorPusher } = require('./mirror/pusher.cjs')
26
26
  const { randomBytes } = require('node:crypto')
27
- const { lanUrls, advertisedCandidates } = require('./relay/lan-network.cjs')
27
+ const { lanUrls, advertisedCandidates, orderCandidates } = require('./relay/lan-network.cjs')
28
28
  const { resolvePort } = require('./relay/port-allocator.cjs')
29
29
  const { createPreviewService } = require('./relay/preview.js')
30
30
  // 本机设备凭据库:/api/relay/revoke-all 必须同时吊销局域网直连的 dshc_ 凭据,
@@ -81,6 +81,9 @@ export const RemoteControlSettingsSchema = z.object({
81
81
  // 环境变量,所以它和其他配置一样存在 relay.json(0600),由 /api/relay/config
82
82
  // 在回环上写入;status / pairing / 二维码都不回显它。
83
83
  registerSecret: z.string().max(512).default(''),
84
+ // 手机优先用哪条地址:空 = 不指定(按宿主网卡优先级排)。选择只挪候选顺序、不删候选,
85
+ // 理由与边界见 relay/lan-network.cjs 的 orderCandidates 与 relay.json 那条地图条目。
86
+ preferredLanAddress: z.string().max(64).default(''),
84
87
  })
85
88
 
86
89
 
@@ -97,6 +100,7 @@ function configOf(state) {
97
100
  // 密钥只往 sidecar 和状态文件走:status() / pairingPayload() 都单独取字段,
98
101
  // 不会把它回显给手机、二维码或日志。
99
102
  registerSecret: typeof state.registerSecret === 'string' ? state.registerSecret : '',
103
+ preferredLanAddress: typeof state.preferredLanAddress === 'string' ? state.preferredLanAddress : '',
100
104
  }
101
105
  }
102
106
 
@@ -149,7 +153,8 @@ function createConfigStore(state) {
149
153
 
150
154
  function pairingPayload(state, lanPort) {
151
155
  const port = Number.isInteger(lanPort) ? lanPort : state.lanPort
152
- const candidates = state.lanEnabled ? advertisedCandidates(port) : []
156
+ // 面板上选过的「手机优先用这条」在这里兑现:只挪到最前,其余继续当兜底(App 按顺序挨个试)。
157
+ const candidates = state.lanEnabled ? orderCandidates(advertisedCandidates(port), state.preferredLanAddress) : []
153
158
  const urls = candidates.map(candidate => candidate.url).filter(Boolean)
154
159
  const relayUrl = state.relayUrl || ''
155
160
  const payload = {