dsh-plugin-weapp-gateway 0.8.49 → 0.8.50
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/README.md +7 -0
- package/lib/client.js +20 -40
- package/lib/index.mjs +6 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,6 +6,13 @@
|
|
|
6
6
|
|
|
7
7
|
`dsh-plugin-weapp-gateway` · DeepSeek Harness 移动客户端连接插件
|
|
8
8
|
|
|
9
|
+
### v0.8.50 · 小程序固定中继优先、局域网兜底;自动选择移到 App 层
|
|
10
|
+
|
|
11
|
+
- 小程序模块不再提供「自动选择」,固定为**鲸尾公网 · 小程序**:二维码改为小程序专用 v2 载荷(`routes` 同时包含中继与局域网端点,不生成 `miniProgramRoute`),因此小程序**先连中继、连不上再回落局域网**(旧的 v3 中继专用码不会回落局域网)。
|
|
12
|
+
- 服务端新增 `route: "mini"`:只带局域网兜底地址 + 中继路由表,不泄露公网入口,也不生成 `miniProgramRoute`。
|
|
13
|
+
- 「自动选择」移到「兼容 App(备用)」层,作为 App 直连的默认方案(公网优先、局域网兜底);上游插件的直连选项(局域网 / Cloudflare / Tailscale / 手动地址)保持完整。
|
|
14
|
+
- 说明:上游插件的连接方案下拉里并没有「自动选择」(其内部状态有 auto/auto-lan,但 UI 未暴露,靠场景向导推荐);我们的自动选择保留在 App 层。
|
|
15
|
+
- 测试:auth 覆盖 `route=mini`(中继 + 局域网路由表、无 `miniProgramRoute`);全量测试通过。
|
|
9
16
|
### v0.8.49 · 配对区改为两层:鲸尾公网主用,兼容 App 折叠备用
|
|
10
17
|
|
|
11
18
|
- 第一层常显:**鲸尾公网(小程序 · 主用)** —— 自动选择 / 鲸尾公网 · 小程序、中继状态与「生成小程序二维码」。
|
package/lib/client.js
CHANGED
|
@@ -547,8 +547,7 @@ window.__ModuleLoader__.load({
|
|
|
547
547
|
const [dismissedNotice, setDismissedNotice] = React.useState(() => dismissedRestartInstance)
|
|
548
548
|
// 两个配对模块各自维护方案:鲸尾公网小程序(主用)与兼容 App(折叠备用)。
|
|
549
549
|
const [appUrl, setAppUrl] = React.useState('')
|
|
550
|
-
const [
|
|
551
|
-
const [appRoute, setAppRoute] = React.useState('lan')
|
|
550
|
+
const [appRoute, setAppRoute] = React.useState('auto')
|
|
552
551
|
const [connectionHelpOpen, setConnectionHelpOpen] = React.useState(false)
|
|
553
552
|
const [toolsOpen, setToolsOpen] = React.useState(false)
|
|
554
553
|
const [toolBusy, setToolBusy] = React.useState(false)
|
|
@@ -618,9 +617,8 @@ window.__ModuleLoader__.load({
|
|
|
618
617
|
const revokingIdsRef = React.useRef(new Set())
|
|
619
618
|
const manualAppUrlRef = React.useRef(false)
|
|
620
619
|
const appUrlRef = React.useRef('')
|
|
621
|
-
const appRouteRef = React.useRef('
|
|
620
|
+
const appRouteRef = React.useRef('auto')
|
|
622
621
|
const appRouteChosenRef = React.useRef(false)
|
|
623
|
-
const miniChosenRef = React.useRef(false)
|
|
624
622
|
const cloudflareModeLoadedRef = React.useRef(false)
|
|
625
623
|
|
|
626
624
|
const refresh = React.useCallback(async () => {
|
|
@@ -652,8 +650,7 @@ window.__ModuleLoader__.load({
|
|
|
652
650
|
cloudflareModeLoadedRef.current = true
|
|
653
651
|
setCloudflareMode(statusData.cloudflare.mode || 'quick')
|
|
654
652
|
}
|
|
655
|
-
//
|
|
656
|
-
if (!miniChosenRef.current) setMiniPlan(statusData.pairingMode === 'relay' ? 'relay' : 'auto')
|
|
653
|
+
// 小程序模块固定为鲸尾公网(中继优先、局域网兜底),不再需要方案状态。
|
|
657
654
|
// App 模块地址跟随环境刷新;自定义地址与手动填写的 Tailscale 地址不被覆盖。
|
|
658
655
|
if (appRouteRef.current !== 'custom'
|
|
659
656
|
&& !(appRouteRef.current === 'tailscale' && manualAppUrlRef.current)) {
|
|
@@ -826,11 +823,6 @@ window.__ModuleLoader__.load({
|
|
|
826
823
|
}, [qr])
|
|
827
824
|
|
|
828
825
|
|
|
829
|
-
const chooseMiniPlan = (plan) => {
|
|
830
|
-
setQr(null)
|
|
831
|
-
miniChosenRef.current = true
|
|
832
|
-
setMiniPlan(plan)
|
|
833
|
-
}
|
|
834
826
|
|
|
835
827
|
// App 模块方案:自定义地址与手动 Tailscale 地址不随轮询覆盖。
|
|
836
828
|
const chooseAppRoute = (route) => {
|
|
@@ -935,19 +927,8 @@ window.__ModuleLoader__.load({
|
|
|
935
927
|
try {
|
|
936
928
|
let data
|
|
937
929
|
if (module === 'mini') {
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
const modeData = await request('/mgw/mode', {
|
|
941
|
-
method: 'POST',
|
|
942
|
-
headers: { 'Content-Type': 'application/json' },
|
|
943
|
-
body: JSON.stringify({ mode: 'relay' }),
|
|
944
|
-
})
|
|
945
|
-
setStatus((current) => ({ ...(current || {}), pairingMode: modeData.pairingMode, relay: modeData.relay }))
|
|
946
|
-
}
|
|
947
|
-
data = await requestPairing({})
|
|
948
|
-
} else {
|
|
949
|
-
data = await requestPairing({ route: 'auto' })
|
|
950
|
-
}
|
|
930
|
+
// 小程序专用路线:中继优先、局域网兜底(路线由小程序端按路由表选择)。
|
|
931
|
+
data = await requestPairing({ route: 'mini' })
|
|
951
932
|
} else {
|
|
952
933
|
data = await requestPairing({
|
|
953
934
|
publicUrl: appRoute === 'tailscale' ? tailscaleEndpointOf(appUrl, status) : appUrl,
|
|
@@ -1140,6 +1121,7 @@ window.__ModuleLoader__.load({
|
|
|
1140
1121
|
const appPairingDisabled = busy || !(status && status.gatewayEnabled) ||
|
|
1141
1122
|
(appRoute === 'custom' && !appUrl.trim()) ||
|
|
1142
1123
|
(appRoute === 'cloudflare' && !cloudflareReady) ||
|
|
1124
|
+
(appRoute === 'auto' && !lanPairingUrl(status)) ||
|
|
1143
1125
|
(appRoute === 'lan' && !lanPairingUrl(status)) ||
|
|
1144
1126
|
(appRoute === 'tailscale' && !(status?.lan?.listening && isTailscaleInput(appUrl)))
|
|
1145
1127
|
|
|
@@ -1353,10 +1335,10 @@ window.__ModuleLoader__.load({
|
|
|
1353
1335
|
}, '?'),
|
|
1354
1336
|
connectionHelpOpen ? React.createElement('div', { id: 'mgw-route-help', role: 'tooltip', style: styles.helpBubble },
|
|
1355
1337
|
React.createElement('strong', null, '怎么选连接方式'),
|
|
1356
|
-
helpLine('小程序连接(推荐)', '鲸尾小程序在微信里通过鲸尾公网中继连接,不受 wss
|
|
1357
|
-
helpLine('
|
|
1358
|
-
helpLine('
|
|
1359
|
-
helpLine('
|
|
1338
|
+
helpLine('小程序连接(推荐)', '鲸尾小程序在微信里通过鲸尾公网中继连接,不受 wss 域名限制;手机与网关在同一局域网时自动兜底直连。'),
|
|
1339
|
+
helpLine('鲸尾公网 · 小程序', '小程序专用二维码:中继优先、局域网兜底;无需公网域名。'),
|
|
1340
|
+
helpLine('兼容 App(备用)', 'DSH App 使用直连入口:自动选择、局域网直连、Cloudflare 外网、Tailscale 私有网络或公网/手动地址。'),
|
|
1341
|
+
helpLine('自动选择(App)', '优先已就绪的公网入口,同时保留局域网与 Tailscale 地址;没有公网入口时使用局域网。'),
|
|
1360
1342
|
helpLine('局域网直连', '手机与 DSH 在同一个可互访的局域网,使用 ws:// 私有地址;离开该网络就无法直连。'),
|
|
1361
1343
|
helpLine('Cloudflare 外网', 'PC 主动连接 Cloudflare,外网用固定域名的 wss://;需要 Cloudflare 账户和域名。'),
|
|
1362
1344
|
helpLine('Tailscale 私有网络', '可检测本机地址,或填写主机的 100.x 私有地址;手机与电脑需登录同一 tailnet。'),
|
|
@@ -1368,15 +1350,11 @@ window.__ModuleLoader__.load({
|
|
|
1368
1350
|
React.createElement('div', { style: { marginTop: 6 } }, advice.remote),
|
|
1369
1351
|
React.createElement('div', { style: { color: colors.muted, marginTop: 6 } }, '面板无法判断手机当前网络;请按手机所在位置选择,提示不会替你修改选择。')))
|
|
1370
1352
|
: null),
|
|
1371
|
-
React.createElement('p', { style: styles.muted }, '
|
|
1372
|
-
React.createElement('div', { style: { display: 'flex', alignItems: 'center', flexWrap: 'wrap', gap: '8px 14px', maxWidth: '100%' } },
|
|
1373
|
-
|
|
1374
|
-
React.createElement('
|
|
1375
|
-
React.createElement('
|
|
1376
|
-
? '鲸尾公网 · 小程序' : '鲸尾公网 · 尚未注册'))),
|
|
1377
|
-
React.createElement('p', { style: { ...styles.muted, margin: '-6px 0 10px' } }, miniPlan === 'relay'
|
|
1378
|
-
? '此方案生成仅供鲸尾小程序使用的中继二维码;App 请展开下方「兼容 App(备用)」。'
|
|
1379
|
-
: '自动选择会优先已就绪的公网入口,同时保留局域网与 Tailscale 地址;小程序没有公网入口时自动使用已注册的鲸尾中继;App 也可使用该二维码。生成新二维码不会断开已连接设备。'),
|
|
1353
|
+
React.createElement('p', { style: styles.muted }, '小程序默认通过鲸尾公网中继连接,不需要公网域名;手机与网关在同一局域网时自动兜底直连。'),
|
|
1354
|
+
React.createElement('div', { style: { display: 'flex', alignItems: 'center', flexWrap: 'wrap', gap: '8px 14px', maxWidth: '100%', marginBottom: 2 } },
|
|
1355
|
+
React.createElement('strong', { style: { fontWeight: 600 } }, '鲸尾公网 · 小程序'),
|
|
1356
|
+
React.createElement('span', { style: styles.muted }, '中继优先,局域网兜底'),
|
|
1357
|
+
status?.relay ? null : React.createElement('span', { style: { ...styles.muted, color: colors.danger, fontWeight: 500 } }, '尚未注册中继')),
|
|
1380
1358
|
// 中继信息块属于小程序模块(自动选择 / 鲸尾公网中继)。
|
|
1381
1359
|
(relayInfo || relayConnector?.running || relayConnector?.delegatedTo || relayConnector?.lastError)
|
|
1382
1360
|
? (relayInfo
|
|
@@ -1401,11 +1379,12 @@ window.__ModuleLoader__.load({
|
|
|
1401
1379
|
: null,
|
|
1402
1380
|
React.createElement('div', { style: { display: 'flex', alignItems: 'center', gap: 12, flexWrap: 'wrap', marginTop: 10 } },
|
|
1403
1381
|
React.createElement('button', {
|
|
1404
|
-
style: { ...styles.button, ...styles.primary, opacity: busy || !(status && status.gatewayEnabled) ||
|
|
1405
|
-
disabled: busy || !(status && status.gatewayEnabled) ||
|
|
1382
|
+
style: { ...styles.button, ...styles.primary, opacity: busy || !(status && status.gatewayEnabled) || !status?.relay || !lanPairingUrl(status) ? .65 : 1 },
|
|
1383
|
+
disabled: busy || !(status && status.gatewayEnabled) || !status?.relay || !lanPairingUrl(status),
|
|
1406
1384
|
onClick: () => pairFor('mini'),
|
|
1407
1385
|
}, busy ? '正在生成…' : !(status && status.gatewayEnabled) ? '请先开启移动网关'
|
|
1408
|
-
:
|
|
1386
|
+
: !status?.relay ? '请先注册鲸尾公网中继'
|
|
1387
|
+
: !lanPairingUrl(status) ? '请先开启局域网入口' : '生成小程序二维码'),
|
|
1409
1388
|
React.createElement('span', { style: styles.muted }, '配对码仅可使用一次,5 分钟内有效。'))),
|
|
1410
1389
|
// ── 第二层:兼容 App(折叠备用)────────────────────────────────
|
|
1411
1390
|
React.createElement('section', { style: { ...styles.card, marginTop: 16 } },
|
|
@@ -1425,6 +1404,7 @@ window.__ModuleLoader__.load({
|
|
|
1425
1404
|
React.createElement('p', { style: styles.muted }, '仅用于 DSH App(上游移动网关的直连方式),与上方鲸尾公网互不影响。'),
|
|
1426
1405
|
React.createElement('div', { style: { display: 'flex', alignItems: 'center', flexWrap: 'wrap', gap: '8px 14px', maxWidth: '100%' } },
|
|
1427
1406
|
React.createElement(GatewaySelect, { style: styles.input, value: appRoute, onChange: (event) => chooseAppRoute(event.target.value), disabled: !status, 'aria-label': 'App 连接方式' },
|
|
1407
|
+
React.createElement('option', { value: 'auto' }, '自动选择'),
|
|
1428
1408
|
React.createElement('option', { value: 'lan', disabled: !lanPairingUrl(status) }, lanPairingUrl(status)
|
|
1429
1409
|
? '局域网直连'
|
|
1430
1410
|
: '局域网直连 · 当前不可用'),
|
package/lib/index.mjs
CHANGED
|
@@ -3523,7 +3523,7 @@ const plugin = {
|
|
|
3523
3523
|
throw error
|
|
3524
3524
|
}
|
|
3525
3525
|
const body = await readBody(req)
|
|
3526
|
-
const clientRoute = ['auto', 'lan', 'cloudflare', 'custom', 'tailscale'].includes(body.route) ? body.route : null
|
|
3526
|
+
const clientRoute = ['auto', 'mini', 'lan', 'cloudflare', 'custom', 'tailscale'].includes(body.route) ? body.route : null
|
|
3527
3527
|
const cloudflareStatus = tunnel?.snapshot() || null
|
|
3528
3528
|
const configuredUrl = configuredPublicUrl()
|
|
3529
3529
|
const autoUrl = cloudflareStatus?.enabled && cloudflareStatus.publicReady === true
|
|
@@ -3565,11 +3565,15 @@ const plugin = {
|
|
|
3565
3565
|
return parsed.toString()
|
|
3566
3566
|
})()
|
|
3567
3567
|
: ''
|
|
3568
|
+
// route=mini 是小程序专用路线:不带公网入口,载荷只含局域网兜底 +
|
|
3569
|
+
// 中继路由表(客户端中继优先、局域网兜底),也不生成 miniProgramRoute。
|
|
3568
3570
|
const publicUrl = clientRoute === 'tailscale'
|
|
3569
3571
|
? requestedTailscaleUrl
|
|
3570
3572
|
: clientRoute === 'auto'
|
|
3571
3573
|
? (autoUrl ? normalizePublicUrl(autoUrl, req, wsPath) : '')
|
|
3572
|
-
:
|
|
3574
|
+
: clientRoute === 'mini'
|
|
3575
|
+
? ''
|
|
3576
|
+
: normalizePublicUrl(body.publicUrl || configuredUrl, req, wsPath)
|
|
3573
3577
|
if (clientRoute) {
|
|
3574
3578
|
const discoveredLan = lanListening
|
|
3575
3579
|
? lanWebSocketUrls(options, wsPath, lanBoundPort).find(isRoutablePrivateEndpoint)
|