dsh-mobile-plugin 0.5.136 → 0.5.138
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/config/agent-presets/standard/skills/dsh-mobile-kb/references/port-conflict.md +4 -4
- package/lib/impl.js +2 -1
- package/lib/mobile/approval-facts.js +12 -0
- package/lib/mobile/patch-files.js +46 -0
- package/lib/mobile/step-index.js +7 -0
- package/lib/panel/index.html +17 -17
- package/lib/shared/route-order.cjs +21 -2
- package/lib/zeronews/wiring.cjs +17 -6
- package/package.json +15 -15
|
@@ -7,6 +7,7 @@ function createRoutePolicy() {
|
|
|
7
7
|
exports.advanceRouteEvidenceRound = advanceRouteEvidenceRound;
|
|
8
8
|
exports.noteRouteLatency = noteRouteLatency;
|
|
9
9
|
exports.noteRouteFailure = noteRouteFailure;
|
|
10
|
+
exports.noteStreamDrop = noteStreamDrop;
|
|
10
11
|
exports.noteRouteProven = noteRouteProven;
|
|
11
12
|
exports.noteRouteVerified = noteRouteVerified;
|
|
12
13
|
exports.noteRouteForeign = noteRouteForeign;
|
|
@@ -26,6 +27,9 @@ function createRoutePolicy() {
|
|
|
26
27
|
const SETTLE_ROUNDS = 4;
|
|
27
28
|
const FAMILY_FAILURE_TRIGGER = 2;
|
|
28
29
|
const FAMILY_COOL_ROUNDS = 4;
|
|
30
|
+
const STREAM_DROP_STEP = 1.5;
|
|
31
|
+
const STREAM_DROP_MAX = 3;
|
|
32
|
+
const STREAM_DROP_DECAY_ROUNDS = 6;
|
|
29
33
|
const factsByScope = new Map();
|
|
30
34
|
function factsOf(scope) {
|
|
31
35
|
let facts = factsByScope.get(scope);
|
|
@@ -33,7 +37,7 @@ function createRoutePolicy() {
|
|
|
33
37
|
facts = {
|
|
34
38
|
latency: new Map(), samples: new Map(), lossPenalty: new Map(), failurePenalty: new Map(),
|
|
35
39
|
foreign: new Set(), evidenceAtRound: new Map(), evidenceRound: 0, staleRounds: 2, lastSwitch: null,
|
|
36
|
-
familyFails: new Map(),
|
|
40
|
+
familyFails: new Map(), streamDrops: new Map(),
|
|
37
41
|
};
|
|
38
42
|
factsByScope.set(scope, facts);
|
|
39
43
|
}
|
|
@@ -72,6 +76,10 @@ function createRoutePolicy() {
|
|
|
72
76
|
if (facts.evidenceRound - entry.atRound > FAMILY_COOL_ROUNDS)
|
|
73
77
|
facts.familyFails.delete(family);
|
|
74
78
|
}
|
|
79
|
+
for (const [key, entry] of facts.streamDrops) {
|
|
80
|
+
if (facts.evidenceRound - entry.atRound > STREAM_DROP_DECAY_ROUNDS)
|
|
81
|
+
facts.streamDrops.delete(key);
|
|
82
|
+
}
|
|
75
83
|
if (facts.lastSwitch && facts.evidenceRound - facts.lastSwitch.round > SETTLE_ROUNDS)
|
|
76
84
|
facts.lastSwitch = null;
|
|
77
85
|
}
|
|
@@ -112,6 +120,15 @@ function createRoutePolicy() {
|
|
|
112
120
|
facts.familyFails.set(family, entry);
|
|
113
121
|
}
|
|
114
122
|
}
|
|
123
|
+
function noteStreamDrop(url, scope = '') {
|
|
124
|
+
const key = norm(url);
|
|
125
|
+
if (!key)
|
|
126
|
+
return;
|
|
127
|
+
const facts = factsOf(scope);
|
|
128
|
+
const prev = facts.streamDrops.get(key);
|
|
129
|
+
const penalty = Math.min(STREAM_DROP_MAX, (prev?.penalty ?? 1) * STREAM_DROP_STEP);
|
|
130
|
+
facts.streamDrops.set(key, { penalty, atRound: facts.evidenceRound });
|
|
131
|
+
}
|
|
115
132
|
function noteRouteProven(url, scope = '') {
|
|
116
133
|
const key = norm(url);
|
|
117
134
|
if (!key)
|
|
@@ -143,7 +160,9 @@ function createRoutePolicy() {
|
|
|
143
160
|
return facts && isFresh(facts, key) ? facts.latency.get(key) ?? null : null;
|
|
144
161
|
}
|
|
145
162
|
function penaltyFor(facts, key) {
|
|
146
|
-
return (facts.lossPenalty.get(key) ?? 1)
|
|
163
|
+
return (facts.lossPenalty.get(key) ?? 1)
|
|
164
|
+
* (facts.failurePenalty.get(key) ?? 1)
|
|
165
|
+
* (facts.streamDrops.get(key)?.penalty ?? 1);
|
|
147
166
|
}
|
|
148
167
|
function routeCostOf(url, scope = '') {
|
|
149
168
|
const facts = factsByScope.get(scope);
|
package/lib/zeronews/wiring.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// 2026-11-28:退让时隧道端口跟判据走;入口判据翻转就重连,让官方 set-local 原地改落点。
|
|
1
2
|
// 2026-11-28:客户端换代:新版预下到 <bin>.next,没人连着时换上去,起不来自动换回旧版。
|
|
2
3
|
// 2026-11-27:连上后落盘客户端身份,复用本机客户端前交给 runner 比对,另一个身份占位不冒充已连接。
|
|
3
4
|
// 2026-11-26:运行中才点连接时补挂体检定时器,否则客户端静默退出没人发现、线路卡在假连接。
|
|
@@ -128,6 +129,8 @@ const facade = {
|
|
|
128
129
|
prepare: () => (readCurrent() ? readCurrent().prepare() : Promise.resolve({ ok: false, error: '这台宿主没有接入 ZeroNews 线路能力' })),
|
|
129
130
|
account: () => (readCurrent() ? readCurrent().account() : Promise.resolve({ ok: false, available: false, error: '这台宿主没有接入 ZeroNews 线路能力' })),
|
|
130
131
|
purge: () => (readCurrent() ? readCurrent().purge() : Promise.resolve({ ok: false, error: '这台宿主没有接入 ZeroNews 线路能力' })),
|
|
132
|
+
// 入口判据翻转(回环被占 / 换端口)时叫一次:已配置才重连,让 runner 认出落点失配并原地改端口。
|
|
133
|
+
reconcile: () => (readCurrent() ? readCurrent().reconcile() : Promise.resolve()),
|
|
131
134
|
};
|
|
132
135
|
|
|
133
136
|
/** @param {{mount:Function, settings:object, getState:Function, control:object, warn:Function, ctx:object, name:string, portOf?:Function, runnerFactory?:Function, ensure?:Function, accountFactory?:Function, loginFlow?:Function, loginClient?:string, openUrl?:Function, onRouteStale?:Function}} options */
|
|
@@ -207,15 +210,17 @@ function mountZeroNews(options) {
|
|
|
207
210
|
return { ...current, configured: current.configured === true || getState().zeroNewsBound === true };
|
|
208
211
|
};
|
|
209
212
|
|
|
210
|
-
//
|
|
211
|
-
//
|
|
212
|
-
//
|
|
213
|
+
// 落点端口按当前判据走:判据在退让时会给出专属入口、用户换局域网端口时给出新值,
|
|
214
|
+
// 旧隧道的落点由 endpoints 读出来比对,runner 认出失配就用官方 set-local 原地改过去。
|
|
215
|
+
// 只有判据没给端口(老宿主取值器缺失)时才沿用 runner 记住的旧落点。
|
|
213
216
|
const preferredPort = () => Number(options.portOf && options.portOf()) || 0;
|
|
214
217
|
let runner = null;
|
|
215
218
|
const tunnelPort = () => {
|
|
216
219
|
const current = runner && typeof runner.status === 'function' ? runner.status() : null;
|
|
217
220
|
const known = current ? Number(current.tunnelLocalPort) : 0;
|
|
218
|
-
|
|
221
|
+
const preferred = preferredPort();
|
|
222
|
+
if (Number.isInteger(preferred) && preferred > 0) return preferred;
|
|
223
|
+
return Number.isInteger(known) && known > 0 ? known : 0;
|
|
219
224
|
};
|
|
220
225
|
// 客户端换代(蓝绿式换法):新版先预热到 `<bin>.next`,客户端停下来之后才动盘;
|
|
221
226
|
// 新起来没连上就把旧版换回来。换客户端必然断一次线,所以只在没有手机长连接的时候换。
|
|
@@ -284,7 +289,10 @@ function mountZeroNews(options) {
|
|
|
284
289
|
// notify:false:只落盘并改内存状态,不走 watch → applyServices → control.sync(),
|
|
285
290
|
// 免得「configured 就自动重连」那条 mount effect 被同一份状态变更反复叫醒。
|
|
286
291
|
if (result && result.phase === 'error' && result.errorReason === 'port-mismatch' && getState().zeroNewsUrl) {
|
|
287
|
-
try {
|
|
292
|
+
try {
|
|
293
|
+
await settings.update({ zeroNewsUrl: '' }, { notify: false });
|
|
294
|
+
if (onRouteStale) onRouteStale();
|
|
295
|
+
}
|
|
288
296
|
catch (error) { warn('清掉失配的 ZeroNews 旧地址失败:%s', error && error.message ? error.message : error); }
|
|
289
297
|
}
|
|
290
298
|
// 一旦确认这台机器有身份就落盘标记,面板下次不必再让人粘一遍 token(token 本身不存)。
|
|
@@ -301,6 +309,9 @@ function mountZeroNews(options) {
|
|
|
301
309
|
return statusOf();
|
|
302
310
|
};
|
|
303
311
|
|
|
312
|
+
/** 入口判据翻转时重连一次:只把当前落点交给 runner 比对,已配置才动,不碰用户主动断开的状态。 */
|
|
313
|
+
const reconcile = () => start(undefined, true);
|
|
314
|
+
|
|
304
315
|
/** 有没有手机正连着:有就不换客户端,等下一拍空档。 */
|
|
305
316
|
const phonesConnected = () => {
|
|
306
317
|
try { return Number(activeConnections()) > 0; } catch { return false; }
|
|
@@ -519,7 +530,7 @@ function mountZeroNews(options) {
|
|
|
519
530
|
return { ok: result.ok === true, ...result, stopped };
|
|
520
531
|
};
|
|
521
532
|
|
|
522
|
-
globalThis[GLOBAL_KEY] = { start, stop, status: statusOf, prepare, account, purge };
|
|
533
|
+
globalThis[GLOBAL_KEY] = { start, stop, status: statusOf, prepare, account, purge, reconcile };
|
|
523
534
|
|
|
524
535
|
mount('ZeroNews 线路', () => ctx.effect(() => {
|
|
525
536
|
// 显式关闭不恢复;旧配置未设开关时仍可沿用上次地址。连不上不阻塞启动。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-mobile-plugin",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.138",
|
|
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,23 +117,23 @@
|
|
|
117
117
|
"yaml": "2.9.1"
|
|
118
118
|
},
|
|
119
119
|
"dshMobileReleaseNotes": {
|
|
120
|
-
"version": "0.5.
|
|
120
|
+
"version": "0.5.138",
|
|
121
121
|
"kinds": [
|
|
122
|
-
"
|
|
123
|
-
"
|
|
122
|
+
"fix",
|
|
123
|
+
"feature"
|
|
124
124
|
],
|
|
125
125
|
"notes": {
|
|
126
|
-
"zh-Hans": "-
|
|
127
|
-
"zh-Hant": "-
|
|
128
|
-
"en": "-
|
|
129
|
-
"ja": "- ZeroNews
|
|
130
|
-
"ko": "-
|
|
131
|
-
"de": "-
|
|
132
|
-
"es": "-
|
|
133
|
-
"fr": "-
|
|
134
|
-
"pt": "-
|
|
135
|
-
"ru": "-
|
|
136
|
-
"tr": "-
|
|
126
|
+
"zh-Hans": "- 端口被占用时 ZeroNews 隧道会自动改到新的专属入口,域名不变,不用删旧隧道重建\n- 面板报错按界面语言显示,外文界面不再夹中文原文\n- 安卓下载渠道按界面语言排序,地区默认两页统一",
|
|
127
|
+
"zh-Hant": "- 連接埠被佔用時 ZeroNews 隧道會自動改到新的專屬入口,網域不變,不用刪舊隧道重建\n- 面板報錯按介面語言顯示,外文介面不再夾中文原文\n- 安卓下載渠道按介面語言排序,地區預設兩頁統一",
|
|
128
|
+
"en": "- When a port is occupied, the ZeroNews tunnel repoints itself to the new dedicated entry: the domain stays the same and the old tunnel does not need deleting or rebuilding.\n- Panel errors now follow your interface language instead of showing raw Chinese text on non-Chinese screens.\n- Android download links are ordered by interface language, and region defaults are consistent across pages.",
|
|
129
|
+
"ja": "- ポートが占有されている場合、ZeroNews トンネルは新しい専用入口へ自動的に切り替わります。ドメインは変わらず、古いトンネルを削除して作り直す必要はありません。\n- パネルのエラーは画面の言語で表示され、外国語画面に中国語の本文が混ざらなくなりました。\n- Android のダウンロードリンクは画面言語順に並び、地域の初期値もページ間で統一されました。",
|
|
130
|
+
"ko": "- 포트가 사용 중이면 ZeroNews 터널이 새 전용 진입점으로 자동 전환됩니다. 도메인은 그대로이며, 기존 터널을 삭제하고 다시 만들 필요가 없습니다.\n- 패널 오류가 화면 언어로 표시되어, 외국어 화면에 중국어 원문이 섞이지 않습니다.\n- Android 다운로드 링크는 화면 언어 순으로 정렬되고, 지역 기본값도 페이지 간에 통일되었습니다.",
|
|
131
|
+
"de": "- Wenn ein Port belegt ist, verlegt der ZeroNews-Tunnel seinen Zielport automatisch auf den neuen dedizierten Eingang. Die Domain bleibt gleich, der alte Tunnel muss nicht gelöscht oder neu erstellt werden.\n- Fehlermeldungen im Panel folgen jetzt der Sprache der Oberfläche; fremdsprachige Ansichten zeigen keinen chinesischen Rohtext mehr.\n- Android-Downloadlinks sind nach der Sprache der Oberfläche geordnet, und die Regionsvoreinstellung ist auf allen Seiten einheitlich.",
|
|
132
|
+
"es": "- Cuando un puerto está ocupado, el túnel ZeroNews se redirige automáticamente a la nueva entrada dedicada: el dominio no cambia y no hace falta borrar y recrear el túnel antiguo.\n- Los errores del panel siguen ahora el idioma de la interfaz, así que las pantallas en otros idiomas ya no muestran texto chino sin traducir.\n- Los enlaces de descarga de Android se ordenan según el idioma de la interfaz y la región predeterminada es coherente en todas las páginas.",
|
|
133
|
+
"fr": "- Lorsqu'un port est occupé, le tunnel ZeroNews se redirige automatiquement vers la nouvelle entrée dédiée : le domaine reste le même et il n'est pas nécessaire de supprimer et recréer l'ancien tunnel.\n- Les erreurs du panel suivent désormais la langue de l'interface ; les écrans en d'autres langues n'affichent plus de texte chinois brut.\n- Les liens de téléchargement Android sont triés selon la langue de l'interface et la région par défaut est uniforme d'une page à l'autre.",
|
|
134
|
+
"pt": "- Quando uma porta está ocupada, o túnel ZeroNews é redirecionado automaticamente para a nova entrada dedicada: o domínio não muda e não é preciso excluir e recriar o túnel antigo.\n- Os erros do painel agora seguem o idioma da interface, então telas em outros idiomas não mostram mais texto chinês sem tradução.\n- Os links de download do Android são ordenados pelo idioma da interface e a região padrão é consistente em todas as páginas.",
|
|
135
|
+
"ru": "- Если порт занят, туннель ZeroNews автоматически переключается на новый выделенный вход: домен не меняется, старый туннель не нужно удалять и создавать заново.\n- Сообщения об ошибках в панели теперь соответствуют языку интерфейса, поэтому на других языках больше не появляется китайский текст.\n- Ссылки для скачивания Android упорядочены по языку интерфейса, а регион по умолчанию одинаков на всех страницах.",
|
|
136
|
+
"tr": "- Bir port meşgul olduğunda ZeroNews tüneli otomatik olarak yeni özel giriş noktasına yönlendirilir; alan adı değişmez, eski tüneli silip yeniden oluşturmanız gerekmez.\n- Panel hataları artık arayüz dilini takip eder; diğer dillerdeki ekranlarda ham Çince metin görünmez.\n- Android indirme bağlantıları arayüz diline göre sıralanır ve varsayılan bölge tüm sayfalarda tutarlıdır."
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
}
|