dsh-mobile-plugin 0.5.140 → 0.5.141
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/zeronews/runner.cjs +58 -29
- package/lib/zeronews/wiring.cjs +31 -4
- package/package.json +13 -13
package/lib/zeronews/runner.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// 2026-11-29:本地判活走本机 healthz,不跑官方 CLI,重载窗口里 attach 的客户端静默退出也能发现。
|
|
1
2
|
// 2026-11-29:体检不再自己跑官方 CLI 查状态;面板读账号快照带来的 status 直接传进来判活。
|
|
2
3
|
// 2026-11-28:官方 4.1.1 起可用 `tunnel <id> set-local` 原地把旧隧道改到当前端口,失配时自动改,不再只报错。
|
|
3
4
|
// 2026-11-27:复用本机已在跑的客户端前比对 client_id / cloud_server_addr,另一个身份占位就明确报错不 attach。
|
|
@@ -585,7 +586,43 @@ function createZeroNewsRunner(options = {}) {
|
|
|
585
586
|
}
|
|
586
587
|
|
|
587
588
|
/**
|
|
588
|
-
*
|
|
589
|
+
* 判活落地:daemon 在跑就探隧道落点端口(没人监听判失效);不在跑就打回 error 并回调自愈。
|
|
590
|
+
* 只动本机状态,不删建云端隧道、不跑官方 CLI。两条判活入口(面板快照 / 本地定时器)
|
|
591
|
+
* 只差「在不在跑」怎么读,落地这一拍完全共用。
|
|
592
|
+
*/
|
|
593
|
+
async function applyLiveness(gen) {
|
|
594
|
+
if (gen !== generation || phase !== 'connected') return;
|
|
595
|
+
if (daemonRunning) {
|
|
596
|
+
// CLI 说守护进程在跑、云端也还留着这条隧道,但它指向的本机端口可能已经没人监听
|
|
597
|
+
// (老隧道落在旧端口上):手机拨过去照样连不上。探一下落点,没监听就判失效。
|
|
598
|
+
// 只改本机这份状态:不删云端隧道、不重建(官方 CLI 没公开删除参数,删错不可回滚)。
|
|
599
|
+
const port = tunnelLocalPort;
|
|
600
|
+
if (port > 0) {
|
|
601
|
+
let listening = true;
|
|
602
|
+
try { listening = await probePort(port); } catch { /* 探活本身失败当不知道,别抖掉还能用的线路 */ }
|
|
603
|
+
if (gen !== generation || phase !== 'connected') return;
|
|
604
|
+
if (!listening) {
|
|
605
|
+
attached = false;
|
|
606
|
+
url = '';
|
|
607
|
+
phase = 'error';
|
|
608
|
+
error = `旧隧道指向的本机端口 ${port} 没有服务监听,请在控制台删除旧隧道后重新接入`;
|
|
609
|
+
errorReason = 'port-dead';
|
|
610
|
+
retryable = false;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
attached = false;
|
|
616
|
+
url = '';
|
|
617
|
+
phase = 'error';
|
|
618
|
+
error = 'ZeroNews 客户端意外退出';
|
|
619
|
+
retryable = true;
|
|
620
|
+
errorReason = '';
|
|
621
|
+
if (onUnexpectedExit) { try { onUnexpectedExit(error); } catch { /* 回调失败不影响状态 */ } }
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* 面板读账号快照触发的判活:daemon 是不是还在、隧道落点端口有没有人监听。
|
|
589
626
|
*
|
|
590
627
|
* 2026-11-29 起不再自己跑 CLI:面板进 ZeroNews 页读账号快照时已经跑过一次
|
|
591
628
|
* `status --json`,把那份结果传进来(stGiven)就能判活,不传才兜底跑一次。
|
|
@@ -598,33 +635,25 @@ function createZeroNewsRunner(options = {}) {
|
|
|
598
635
|
const st = stGiven !== undefined ? stGiven : await cliStatus();
|
|
599
636
|
if (gen !== generation || phase !== 'connected' || !st) return;
|
|
600
637
|
daemonRunning = st.running === true;
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
}
|
|
621
|
-
attached = false;
|
|
622
|
-
url = '';
|
|
623
|
-
phase = 'error';
|
|
624
|
-
error = 'ZeroNews 客户端意外退出';
|
|
625
|
-
retryable = true;
|
|
626
|
-
errorReason = '';
|
|
627
|
-
if (onUnexpectedExit) { try { onUnexpectedExit(error); } catch { /* 回调失败不影响状态 */ } }
|
|
638
|
+
await applyLiveness(gen);
|
|
639
|
+
})();
|
|
640
|
+
try { await aliveCheckPromise; } finally { aliveCheckPromise = null; }
|
|
641
|
+
return status();
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* 本地判活(接线层定时体检用):只问本机守护进程的 /healthz,不跑官方 CLI、不碰控制面。
|
|
646
|
+
* 插件重载窗口里客户端静默退出、又是 attach 来的(没有本次 spawn 的 exit 事件)时,
|
|
647
|
+
* 靠这一拍发现:healthz 连不上就打回 error 并回调自愈重连,不用等用户打开面板。
|
|
648
|
+
*/
|
|
649
|
+
async function checkLocalAlive() {
|
|
650
|
+
if (phase !== 'connected' || aliveCheckPromise) return status();
|
|
651
|
+
const gen = generation;
|
|
652
|
+
aliveCheckPromise = (async () => {
|
|
653
|
+
const healthy = await api('/healthz');
|
|
654
|
+
if (gen !== generation || phase !== 'connected') return;
|
|
655
|
+
daemonRunning = Boolean(healthy);
|
|
656
|
+
await applyLiveness(gen);
|
|
628
657
|
})();
|
|
629
658
|
try { await aliveCheckPromise; } finally { aliveCheckPromise = null; }
|
|
630
659
|
return status();
|
|
@@ -649,7 +678,7 @@ function createZeroNewsRunner(options = {}) {
|
|
|
649
678
|
* 那份会原样转发给手机,本机路径不进契约。 */
|
|
650
679
|
function binaryPath() { return binary; }
|
|
651
680
|
|
|
652
|
-
return { start, stop, status, checkAlive, pickEndpoint, endpointUrl, binaryPath };
|
|
681
|
+
return { start, stop, status, checkAlive, checkLocalAlive, pickEndpoint, endpointUrl, binaryPath };
|
|
653
682
|
}
|
|
654
683
|
|
|
655
684
|
module.exports = { DEFAULT_BASE, LOGIN_TIMEOUT_MS, START_TIMEOUT_MS, endpointUrl, pickEndpoint, createZeroNewsRunner };
|
package/lib/zeronews/wiring.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// 2026-11-29:恢复本地判活定时器(只探本机 healthz / 落点端口,不跑官方 CLI),重载窗口里静默退出也能自愈。
|
|
1
2
|
// 2026-11-29:去掉 15 秒定时体检,判活复用面板进 ZeroNews 页读账号快照时带出的 status。
|
|
2
3
|
// 2026-11-28:退让时隧道端口跟判据走;入口判据翻转就重连,让官方 set-local 原地改落点。
|
|
3
4
|
// 2026-11-28:客户端换代:新版预下到 <bin>.next,没人连着时换上去,起不来自动换回旧版。
|
|
@@ -191,6 +192,29 @@ function mountZeroNews(options) {
|
|
|
191
192
|
}
|
|
192
193
|
};
|
|
193
194
|
|
|
195
|
+
/**
|
|
196
|
+
* 本地判活定时器:连着的时候定期问本机守护进程的 /healthz、探隧道落点端口,
|
|
197
|
+
* 不跑官方 CLI、不碰控制面,也不依赖用户打开面板。插件重载窗口里客户端静默退出
|
|
198
|
+
* (attach 来的没有本次 spawn 的 exit 事件)时,运行器把状态打回 error 并回调,
|
|
199
|
+
* 走上面同一条自愈重连。断开、清理、卸载时一并撤掉,不自动删建云端隧道。
|
|
200
|
+
*/
|
|
201
|
+
const localProbeMs = Number(options.localProbeMs) > 0 ? Number(options.localProbeMs) : 20_000;
|
|
202
|
+
let localProbeTimer = null;
|
|
203
|
+
const clearLocalProbe = () => { if (localProbeTimer) { clearTimeout(localProbeTimer); localProbeTimer = null; } };
|
|
204
|
+
const startLocalProbe = () => {
|
|
205
|
+
if (localProbeTimer || typeof runner.checkLocalAlive !== 'function') return;
|
|
206
|
+
localProbeTimer = setTimeout(() => {
|
|
207
|
+
localProbeTimer = null;
|
|
208
|
+
if (!isConfigured()) return;
|
|
209
|
+
void runner.checkLocalAlive().then((result) => {
|
|
210
|
+
applyAliveResult(result);
|
|
211
|
+
// 还在连着才续下一拍;掉线交给 scheduleRetry,port-dead 这类确定性错误就此停手。
|
|
212
|
+
if (isConfigured() && result && result.phase === 'connected') startLocalProbe();
|
|
213
|
+
}).catch(() => { if (isConfigured()) startLocalProbe(); });
|
|
214
|
+
}, localProbeMs);
|
|
215
|
+
if (localProbeTimer && typeof localProbeTimer.unref === 'function') localProbeTimer.unref();
|
|
216
|
+
};
|
|
217
|
+
|
|
194
218
|
/** 身份看过没有:runner 这一进程见过的,或者落盘记录里做过都算。 */
|
|
195
219
|
const statusOf = () => {
|
|
196
220
|
const current = runner.status();
|
|
@@ -248,6 +272,7 @@ function mountZeroNews(options) {
|
|
|
248
272
|
|
|
249
273
|
const start = async (token, automatic = false) => {
|
|
250
274
|
clearRetry();
|
|
275
|
+
clearLocalProbe();
|
|
251
276
|
if (automatic && !isConfigured()) return statusOf();
|
|
252
277
|
let result;
|
|
253
278
|
try {
|
|
@@ -289,8 +314,8 @@ function mountZeroNews(options) {
|
|
|
289
314
|
}
|
|
290
315
|
// 连上就把退避重置;还停在错误上就安排下一轮自愈,实现自动更新 / 重载后自己恢复。
|
|
291
316
|
// 但配额满 / 被拒 / token 冲突这类确定性错误重试也没用,不排(retryable=false),免得无限空转。
|
|
292
|
-
//
|
|
293
|
-
if (result && result.phase === 'connected') { retryMs = retryBaseMs; }
|
|
317
|
+
// 连上就挂本地判活:不打开面板也要能发现客户端静默退出(重载 / 换代 / 偶发崩溃)。
|
|
318
|
+
if (result && result.phase === 'connected') { retryMs = retryBaseMs; startLocalProbe(); }
|
|
294
319
|
else if (result && result.phase === 'error' && result.retryable !== false) scheduleRetry();
|
|
295
320
|
return statusOf();
|
|
296
321
|
};
|
|
@@ -481,6 +506,7 @@ function mountZeroNews(options) {
|
|
|
481
506
|
|
|
482
507
|
const stop = async () => {
|
|
483
508
|
clearRetry();
|
|
509
|
+
clearLocalProbe();
|
|
484
510
|
retryMs = retryBaseMs;
|
|
485
511
|
killLogin();
|
|
486
512
|
const result = runner.stop();
|
|
@@ -513,6 +539,7 @@ function mountZeroNews(options) {
|
|
|
513
539
|
*/
|
|
514
540
|
const purge = async () => {
|
|
515
541
|
clearRetry();
|
|
542
|
+
clearLocalProbe();
|
|
516
543
|
retryMs = retryBaseMs;
|
|
517
544
|
killLogin();
|
|
518
545
|
const stopped = runner.stop();
|
|
@@ -531,9 +558,9 @@ function mountZeroNews(options) {
|
|
|
531
558
|
|
|
532
559
|
mount('ZeroNews 线路', () => ctx.effect(() => {
|
|
533
560
|
// 显式关闭不恢复;旧配置未设开关时仍可沿用上次地址。连不上不阻塞启动。
|
|
534
|
-
//
|
|
561
|
+
// 本地判活定时器由 start() 在连上时挂上;不打开面板也能发现客户端静默退出。
|
|
535
562
|
if (isConfigured()) void start(undefined, true).catch(() => {});
|
|
536
|
-
return () => { clearRetry(); killLogin(); runner.stop(); };
|
|
563
|
+
return () => { clearRetry(); clearLocalProbe(); killLogin(); runner.stop(); };
|
|
537
564
|
}, `${name}: zeronews runner`));
|
|
538
565
|
return facade;
|
|
539
566
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-mobile-plugin",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.141",
|
|
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",
|
|
@@ -117,22 +117,22 @@
|
|
|
117
117
|
"yaml": "2.9.1"
|
|
118
118
|
},
|
|
119
119
|
"dshMobileReleaseNotes": {
|
|
120
|
-
"version": "0.5.
|
|
120
|
+
"version": "0.5.141",
|
|
121
121
|
"kinds": [
|
|
122
122
|
"fix"
|
|
123
123
|
],
|
|
124
124
|
"notes": {
|
|
125
|
-
"zh-Hans": "- ZeroNews
|
|
126
|
-
"zh-Hant": "- ZeroNews
|
|
127
|
-
"en": "- ZeroNews
|
|
128
|
-
"ja": "- ZeroNews
|
|
129
|
-
"ko": "- ZeroNews
|
|
130
|
-
"de": "-
|
|
131
|
-
"es": "- ZeroNews
|
|
132
|
-
"fr": "- ZeroNews ne
|
|
133
|
-
"pt": "-
|
|
134
|
-
"ru": "- ZeroNews
|
|
135
|
-
"tr": "- ZeroNews
|
|
125
|
+
"zh-Hans": "- 修复 ZeroNews 线路在插件重载或自动更新后,本机客户端悄悄退出却没人发现、面板仍显示已连接、手机拨不通的问题。现在改为只在本机做轻量体检,客户端掉了会自动重连;不会反复打扰 ZeroNews 官方服务,也不改端口、不删云端隧道。",
|
|
126
|
+
"zh-Hant": "- 修正 ZeroNews 線路在外掛重載或自動更新後,本機用戶端悄悄結束卻無人發現、面板仍顯示已連線、手機連不上的問題。現在只在本機做輕量體檢,用戶端掉了會自動重連;不會反覆打擾 ZeroNews 官方服務,也不改連線埠、不刪雲端隧道。",
|
|
127
|
+
"en": "- Fixed an issue where, after a plugin reload or automatic update, the local ZeroNews client could exit silently while the panel still showed it as connected and phones could not reach it. A lightweight local health check now detects the drop and reconnects automatically, without repeatedly querying ZeroNews, changing ports, or deleting cloud tunnels.",
|
|
128
|
+
"ja": "- プラグインの再読み込みや自動更新後、ZeroNews のローカルクライアントが静かに終了しても検知されず、パネルは接続済みのまま端末から接続できない問題を修正しました。軽量なローカル診断で切断を検知して自動再接続します。ZeroNews 側への頻繁な照会、ポート変更、クラウドトンネルの削除は行いません。",
|
|
129
|
+
"ko": "- 플러그인 재로드나 자동 업데이트 후 ZeroNews 로컬 클라이언트가 조용히 종료돼도 감지하지 못해 패널은 연결된状态和 유지되며 휴대폰이 연결되지 않던 문제를 수정했습니다. 이제 가벼운 로컬 상태 확인으로 끊김을 감지해 자동 재연결합니다. ZeroNews 서버를 자주 조회하거나 포트를 바꾸거나 클라우드 터널을 삭제하지 않습니다.",
|
|
130
|
+
"de": "- Behoben: Nach einem Plugin-Reload oder einer automatischen Aktualisierung konnte der lokale ZeroNews-Client leise beendet werden, ohne dass es bemerkt wurde. Das Panel zeigte weiter „verbunden“, während das Telefon keine Verbindung bekam. Eine leichte lokale Prüfung erkennt den Ausfall jetzt und stellt die Verbindung automatisch wieder her – ohne wiederholte Abfragen bei ZeroNews, ohne Portänderung und ohne Löschen von Cloud-Tunneln.",
|
|
131
|
+
"es": "- Se corrigió un problema en el que, tras recargar o actualizar automáticamente el complemento, el cliente local de ZeroNews salía silenciosamente sin que se detectara: el panel seguía mostrando «conectado» y el teléfono no podía acceder. Ahora una comprobación local ligera detecta la caída y reconecta automáticamente, sin consultar repetidamente a ZeroNews, cambiar puertos ni borrar túneles en la nube.",
|
|
132
|
+
"fr": "- Correction d'un problème où, après un rechargement ou une mise à jour automatique du plugin, le client local ZeroNews quittait silencieusement sans être détecté : le panneau affichait toujours « connecté » alors que le téléphone ne pouvait plus accéder. Une légère vérification locale détecte désormais la coupure et relance la connexion automatiquement, sans interroger ZeroNews en boucle, sans changer de port et sans supprimer les tunnels cloud.",
|
|
133
|
+
"pt": "- Corrigido um problema em que, após recarregar ou atualizar automaticamente o plugin, o cliente local do ZeroNews saía silenciosamente sem ser detectado: o painel continuava mostrando «conectado» e o telemóvel não conseguia ligar. Agora uma verificação local leve detecta a queda e reconecta automaticamente, sem consultar o ZeroNews repetidamente, sem alterar portas e sem apagar túneis na nuvem.",
|
|
134
|
+
"ru": "- Исправлена проблема, когда после перезагрузки или автообновления плагина локальный клиент ZeroNews тихо завершался, а приложение продолжало показывать «подключено» и телефон не мог подключиться. Теперь легкая локальная проверка обнаруживает обрыв и автоматически восстанавливает соединение — без частых запросов к ZeroNews, смены портов и удаления облачных туннелей.",
|
|
135
|
+
"tr": "- Eklentinin yeniden yüklenmesi veya otomatik güncellemeden sonra yerel ZeroNews istemcisinin sessizce kapanıp fark edilmemesi, panelin bağlı görünmesine karşın telefonun bağlanamaması sorunu düzeltildi. Artık hafif bir yerel kontrol kopmayı algılayıp otomatik yeniden bağlanıyor; ZeroNews'a sürekli sorgu gönderilmiyor, port değiştirilmiyor ve bulut tünelleri silinmiyor."
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
}
|