dsh-plugin-weapp-gateway 0.8.60 → 0.8.61
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 +5 -0
- package/lib/cloudflare-tunnel.mjs +23 -0
- package/lib/index.mjs +5 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,6 +6,11 @@
|
|
|
6
6
|
|
|
7
7
|
`dsh-plugin-weapp-gateway` · DeepSeek Harness 移动客户端连接插件
|
|
8
8
|
|
|
9
|
+
### v0.8.61 · Quick Tunnel 自愈与 Tailscale Serve 进自动候选
|
|
10
|
+
|
|
11
|
+
- **Cloudflare Quick Tunnel 定时自愈**:隧道在线后每 60 秒探测一次公网入口;`trycloudflare.com` 地址失效或不可达时自动重启 cloudflared,重新取得可用地址,避免手机拿着过期 URL 一直连不上。隧道进程退出时会清除定时器,重启后不会残留持有旧进程句柄的检查(否则新隧道不可达时无法触发重启)。
|
|
12
|
+
- **auto 配对路线纳入 Tailscale Serve**:`tailscale serve` 已就绪时,其 `wss://<node>.<tailnet>.ts.net/ws/mobile` 会作为公网候选一并写进配对载荷(与 Cloudflare 并存),客户端按自身优先级选路;两条公网通道可同时开启,互不影响。
|
|
13
|
+
- 全量测试通过(20 个 node:test 文件 + 15 个测试链)。
|
|
9
14
|
### v0.8.60 · 同步上游 0.12.2(Linux 后台服务 + 健康摘要 v2)
|
|
10
15
|
|
|
11
16
|
- **Linux 持久化后台运行**:通用设置新增开关(仅 Linux 且通过 `dsh web` 启动时显示)。开启后由 systemd 用户服务托管整个 DSH Web:SSH 断开继续运行、开机自启、异常退出自动重启(60 秒内最多 5 次);写入 `0600` 启动快照与服务单元,服务名 `dsh-weapp-gateway-<id>.service`。关闭只取消自启,当前进程继续运行。后台托管时工具菜单的重启/停止改由 systemd 执行。
|
|
@@ -82,6 +82,7 @@ export function createCloudflareTunnel({ file, port = 3082, wsPath, executable =
|
|
|
82
82
|
let endpointHealth = { state: 'unchecked', message: '尚未检测公网 DNS、TLS 和 WebSocket 路由。' }
|
|
83
83
|
let healthGeneration = 0
|
|
84
84
|
let healthPending = null
|
|
85
|
+
let healthTimer = null
|
|
85
86
|
const checkEndpoint = () => {
|
|
86
87
|
const endpoint = publicUrl()
|
|
87
88
|
if (!shouldRun() || !endpoint || phase !== 'online') return Promise.resolve(snapshot())
|
|
@@ -115,6 +116,8 @@ export function createCloudflareTunnel({ file, port = 3082, wsPath, executable =
|
|
|
115
116
|
})
|
|
116
117
|
|
|
117
118
|
const stop = async () => {
|
|
119
|
+
if (healthTimer) clearInterval(healthTimer)
|
|
120
|
+
healthTimer = null
|
|
118
121
|
healthGeneration += 1
|
|
119
122
|
healthPending = null
|
|
120
123
|
endpointHealth = { state: 'unchecked', message: '尚未检测公网 DNS、TLS 和 WebSocket 路由。' }
|
|
@@ -182,6 +185,22 @@ export function createCloudflareTunnel({ file, port = 3082, wsPath, executable =
|
|
|
182
185
|
phase = 'online'
|
|
183
186
|
error = null
|
|
184
187
|
if (firstOnline) void checkEndpoint()
|
|
188
|
+
// 定时健康检查:quick tunnel 的 URL 会随重启变化/失效,检测到不可达就重启隧道并刷新 URL
|
|
189
|
+
if (!healthTimer) {
|
|
190
|
+
healthTimer = setInterval(() => {
|
|
191
|
+
if (phase !== 'online' || !shouldRun()) return
|
|
192
|
+
const endpoint = publicUrl()
|
|
193
|
+
if (!endpoint) return
|
|
194
|
+
void probeEndpoint(endpoint).then((health) => {
|
|
195
|
+
endpointHealth = health
|
|
196
|
+
if (health.state !== 'reachable') {
|
|
197
|
+
log('Cloudflare endpoint unreachable, restarting tunnel: ' + endpoint)
|
|
198
|
+
try { running.kill() } catch { /* already gone */ }
|
|
199
|
+
}
|
|
200
|
+
}).catch(() => {})
|
|
201
|
+
}, 60_000)
|
|
202
|
+
healthTimer.unref?.()
|
|
203
|
+
}
|
|
185
204
|
}
|
|
186
205
|
}
|
|
187
206
|
running.stderr?.on('data', onOutput)
|
|
@@ -189,6 +208,10 @@ export function createCloudflareTunnel({ file, port = 3082, wsPath, executable =
|
|
|
189
208
|
const exited = (reason) => {
|
|
190
209
|
if (child !== running) return
|
|
191
210
|
child = null
|
|
211
|
+
// 隧道进程结束时要停掉健康检查,否则重启后会残留一个持有旧进程句柄的定时器,
|
|
212
|
+
// 导致新隧道不可达时无法触发重启。
|
|
213
|
+
if (healthTimer) clearInterval(healthTimer)
|
|
214
|
+
healthTimer = null
|
|
192
215
|
healthGeneration += 1
|
|
193
216
|
healthPending = null
|
|
194
217
|
endpointHealth = { state: 'unchecked', message: '隧道已断开,需重新检测公网入口。' }
|
package/lib/index.mjs
CHANGED
|
@@ -3880,8 +3880,13 @@ const plugin = {
|
|
|
3880
3880
|
})
|
|
3881
3881
|
.slice(0, 16)
|
|
3882
3882
|
: advertisedEndpoints(appUrl).filter(isRoutablePrivateEndpoint)
|
|
3883
|
+
// auto 路线:公网入口同时带上 Cloudflare 与 Tailscale Serve,客户端按
|
|
3884
|
+
// 「Tailscale → Cloudflare → 局域网」优先级自行选择;两者可同时启用。
|
|
3885
|
+
const tailscaleServeEndpoints = clientRoute === 'auto' && serveTailscaleUrl &&
|
|
3886
|
+
isPublicSecureEndpoint(serveTailscaleUrl) ? [serveTailscaleUrl] : []
|
|
3883
3887
|
const appEndpoints = [...new Set([
|
|
3884
3888
|
...(clientRoute !== 'lan' && clientRoute !== 'tailscale' && hasPublicRoute ? [publicUrl] : []),
|
|
3889
|
+
...tailscaleServeEndpoints,
|
|
3885
3890
|
...lanEndpoints,
|
|
3886
3891
|
])].slice(0, 16)
|
|
3887
3892
|
// 全网络自动选路路由表:客户端按自身能力从 lan/public/relay 中挑选,
|