dsh-mobile-plugin 0.5.143 → 0.5.145
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 +2 -2
- package/config/agent-presets/standard/skills/dsh-mobile-kb/SKILL.md +4 -2
- package/config/agent-presets/standard/skills/dsh-mobile-kb/references/harmonyos.md +27 -0
- package/config/agent-presets/standard/skills/dsh-mobile-kb/references/network-guide.md +1 -1
- package/config/agent-presets/standard/skills/dsh-mobile-kb/references/network.md +1 -1
- package/config/agent-presets/standard/skills/dsh-mobile-kb/references/relay-server.md +1 -1
- package/config/agent-presets/standard/skills/dsh-mobile-kb/references/relay.md +8 -9
- package/docs/extension-authoring.md +28 -0
- package/dsh-mobile-credentials/lib/credentials.js +74 -6
- package/lib/cloudflared/wiring.cjs +14 -1
- package/lib/frpc/runner.cjs +14 -5
- package/lib/impl.js +21 -6
- package/lib/mobile/activity.cjs +107 -11
- package/lib/mobile/feedback.js +19 -0
- package/lib/mobile/mux.js +2 -1
- package/lib/mobile/pairing.js +19 -24
- package/lib/mobile/permissions.js +13 -10
- package/lib/mobile/relay-control.js +7 -0
- package/lib/mobile/schedule-edit.js +9 -8
- package/lib/mobile/send-continuation.js +2 -2
- package/lib/mobile/session-send.js +3 -4
- package/lib/p2p/session.cjs +21 -38
- package/lib/panel/index.html +18 -19
- package/lib/relay/config-store.js +5 -0
- package/lib/relay/core.js +6 -43
- package/lib/relay/ipv6-lifetime.cjs +89 -0
- package/lib/relay/lan-discovery.cjs +4 -7
- package/lib/relay/lan-network.cjs +16 -6
- package/lib/relay/lan-port-policy.cjs +6 -14
- package/lib/relay/lan-proxy.js +16 -30
- package/lib/relay/pairing-payload.cjs +76 -2
- package/lib/remote/host-control.cjs +14 -8
- package/lib/routes/control-plane.js +11 -1
- package/lib/routes/mobile-api.js +4 -1
- package/lib/shared/device-headers.js +1 -3
- package/lib/sidecar-facade-worker.cjs +15 -4
- package/lib/tailcat/host-process.cjs +17 -25
- package/lib/zeronews/account.cjs +8 -4
- package/lib/zeronews/probe.cjs +22 -14
- package/lib/zeronews/runner.cjs +26 -5
- package/package.json +14 -13
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// 2026-11-30:Bonjour 广播单独开关;关掉只停发布,局域网监听与配对照旧。
|
|
2
|
+
// 2026-11-29:绑定局域网入口不再传凭据库;换号只看固定端口开关。
|
|
1
3
|
// 2026-11-26:控制台退出事件不再带走 worker,信号处理器抢在依赖加载之前注册。
|
|
2
4
|
// 2026-11-25:专属回环入口随局域网代理一起启动,实绑端口上报宿主落盘;sidecar 白名单放行该运行时字段。
|
|
3
5
|
// 主动重连只重建中转隧道,手工换址先清掉过期的自动选路账。
|
|
@@ -365,6 +367,13 @@ function snapshotRead(info) {
|
|
|
365
367
|
}
|
|
366
368
|
return body
|
|
367
369
|
}
|
|
370
|
+
/**
|
|
371
|
+
* Bonjour 广播要不要发布。入口关着当然不发布;发现开关只有显式 false 才算关,
|
|
372
|
+
* 老配置没这一格、坏值都按开(老行为)。这一位只管发布,不管局域网监听与地址候选。
|
|
373
|
+
*/
|
|
374
|
+
function discoveryPublishingOf(c) {
|
|
375
|
+
return Boolean(c.lanEnabled) && c.lanDiscoveryEnabled !== false
|
|
376
|
+
}
|
|
368
377
|
/**
|
|
369
378
|
* 「这份配置里哪几项决定隧道要重建」。
|
|
370
379
|
*
|
|
@@ -391,7 +400,7 @@ function tunnelSignature(c) {
|
|
|
391
400
|
function lanSignature(c) {
|
|
392
401
|
// **配对码与票据不在其中**:它们由 `currentPairing` 现读,改它们不该重建监听 ——
|
|
393
402
|
// 配对成功就要换一次(§5.1),跟着重建会把刚握上的连接掐掉。
|
|
394
|
-
return JSON.stringify([Boolean(c.enabled), Boolean(c.lanEnabled), c.lanPort || 0, c.tunnelIngressPort || 0, c.upstreamPort || 0, c.upstreamHost || '', c.instanceId || '', c.previousInstanceId || '', c.lanSecret || '', c.pairingTier || 'full'])
|
|
403
|
+
return JSON.stringify([Boolean(c.enabled), Boolean(c.lanEnabled), c.lanDiscoveryEnabled !== false, c.lanPort || 0, c.tunnelIngressPort || 0, c.upstreamPort || 0, c.upstreamHost || '', c.instanceId || '', c.previousInstanceId || '', c.lanSecret || '', c.pairingTier || 'full'])
|
|
395
404
|
}
|
|
396
405
|
/** 「这份配置里哪几项决定网络监视器要不要重排」。 */
|
|
397
406
|
function monitorSignature(c) {
|
|
@@ -762,14 +771,14 @@ async function startLan() {
|
|
|
762
771
|
const own = lanGeneration
|
|
763
772
|
lanRequestedPort = config.lanPort
|
|
764
773
|
lanState = 'connecting'
|
|
765
|
-
const discovery = config
|
|
774
|
+
const discovery = discoveryPublishingOf(config)
|
|
766
775
|
? createLanDiscovery({ instanceId: config.instanceId, onChange: publishState })
|
|
767
776
|
: { publish: async () => false, stop: async () => {}, snapshot: () => ({ state: 'off', error: null }) }
|
|
768
777
|
lanDiscovery = discovery
|
|
769
778
|
publishState()
|
|
770
779
|
try {
|
|
771
780
|
const result = await bindLanEndpoint({
|
|
772
|
-
requestedPort: config.lanPort, lockReason: config.lanPortLockReason || '', discovery,
|
|
781
|
+
requestedPort: config.lanPort, lockReason: config.lanPortLockReason || '', discovery,
|
|
773
782
|
isCurrent: () => own === lanGeneration,
|
|
774
783
|
createProxy: port => createLanProxy({
|
|
775
784
|
ipv4Enabled: Boolean(config.lanEnabled),
|
|
@@ -850,7 +859,7 @@ async function configure(next) {
|
|
|
850
859
|
// `relayUrls` 在白名单里,而且从这一轮起**进签名**(见 tunnelSignature):地址组或它的
|
|
851
860
|
// 顺序变了就要重新择路。白名单缺了它,宿主下发这一格会直接抛 unknown configuration
|
|
852
861
|
// field,整次配置下发失败。
|
|
853
|
-
const allowed = ['enabled', 'relayUrl', 'relayUrls', 'instanceId', 'previousInstanceId', 'pairingCode', 'pairingTicket', 'pairingTier', 'name', 'upstreamPort', 'upstreamHost', 'lanPort', 'lanPortLockReason', 'lanEnabled', 'lanSecret', 'registerSecret', 'tunnelIngressPort', 'ipVersionPolicy']
|
|
862
|
+
const allowed = ['enabled', 'relayUrl', 'relayUrls', 'instanceId', 'previousInstanceId', 'pairingCode', 'pairingTicket', 'pairingTier', 'name', 'upstreamPort', 'upstreamHost', 'lanPort', 'lanPortLockReason', 'lanEnabled', 'lanDiscoveryEnabled', 'lanSecret', 'registerSecret', 'tunnelIngressPort', 'ipVersionPolicy']
|
|
854
863
|
if (Object.keys(next).some(key => !allowed.includes(key))) throw new Error('unknown configuration field')
|
|
855
864
|
if (next.ipVersionPolicy !== undefined && !['auto', 'ipv4-first', 'ipv4-only'].includes(next.ipVersionPolicy)) throw new Error('invalid ipVersionPolicy')
|
|
856
865
|
if (typeof next.instanceId !== 'string' || next.instanceId.length > 128) throw new Error('invalid instanceId')
|
|
@@ -861,6 +870,8 @@ async function configure(next) {
|
|
|
861
870
|
if (typeof next.upstreamPort !== 'number' || !Number.isInteger(next.upstreamPort) || next.upstreamPort < 1 || next.upstreamPort > 65535) throw new Error('invalid upstreamPort')
|
|
862
871
|
if (next.upstreamHost !== undefined && (typeof next.upstreamHost !== 'string' || !next.upstreamHost || next.upstreamHost.length > 64)) throw new Error('invalid upstreamHost')
|
|
863
872
|
if (next.lanPort !== undefined && (!Number.isInteger(next.lanPort) || next.lanPort < 1024 || next.lanPort > 65535)) throw new Error('invalid lanPort')
|
|
873
|
+
// 广播开关只认布尔;缺字段与坏值都按开,但下发的坏形状当场挡住,别让半截配置进监听。
|
|
874
|
+
if (next.lanDiscoveryEnabled !== undefined && typeof next.lanDiscoveryEnabled !== 'boolean') throw new Error('invalid lanDiscoveryEnabled')
|
|
864
875
|
// 专属入口端口是运行时字段(默认 0 = 内核分配);坏值宁可退回分配,也不拿它去听一个死端口。
|
|
865
876
|
if (next.tunnelIngressPort !== undefined && (!Number.isInteger(next.tunnelIngressPort) || next.tunnelIngressPort < 0 || next.tunnelIngressPort > 65535)) throw new Error('invalid tunnelIngressPort')
|
|
866
877
|
if (next.registerSecret !== undefined && (typeof next.registerSecret !== 'string' || next.registerSecret.length > 512)) throw new Error('invalid registerSecret')
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// 2026-11-30:需求变为不接外部组件老形状——助手事件缺 peerKey 直接丢,密码学材料不齐直接抛错。
|
|
1
2
|
// 助手重启读取当前已持久身份与白名单,按 peer 保留 IPC 生命周期;平台表含 Windows ARM64。
|
|
2
3
|
'use strict';
|
|
3
4
|
|
|
@@ -40,9 +41,9 @@ const BACKOFF_MS = [1_000, 2_000, 5_000, 10_000, 30_000];
|
|
|
40
41
|
/** 事件里允许出现的键,多一个少一个都当脏数据丢掉(stdout 是私有 IPC)。 */
|
|
41
42
|
const EVENT_KEYS = {
|
|
42
43
|
ready: ['address'],
|
|
43
|
-
p2pReady: ['url', 'candidates'],
|
|
44
|
-
p2pStopped: [],
|
|
45
|
-
p2pStatus: ['running', 'url', 'path', 'active', 'detail', 'candidates'],
|
|
44
|
+
p2pReady: ['url', 'candidates', 'peerKey'],
|
|
45
|
+
p2pStopped: ['peerKey'],
|
|
46
|
+
p2pStatus: ['running', 'url', 'path', 'active', 'detail', 'candidates', 'peerKey'],
|
|
46
47
|
p2pKeys: ['private', 'public', 'port'],
|
|
47
48
|
pairing: ['address', 'port', 'key', 'proof', 'expiresAt'],
|
|
48
49
|
paired: ['address', 'client'],
|
|
@@ -51,19 +52,6 @@ const EVENT_KEYS = {
|
|
|
51
52
|
error: ['code'],
|
|
52
53
|
};
|
|
53
54
|
|
|
54
|
-
/**
|
|
55
|
-
* 这些事件**允许**多带一个 `peerKey`(手机公钥),其余键一个不多。
|
|
56
|
-
*
|
|
57
|
-
* 一台电脑同时接多台手机之后,助手报的 `p2pReady` / `p2pStatus` 是「哪一台的」必须能分开,
|
|
58
|
-
* 否则插件没法把状态路由到对应那台。但这条 IPC 的严格白名单照旧:只给这两个事件开这一个
|
|
59
|
-
* 可选键,其余键、其余事件多一个字节都还是脏数据。老助手不发这一格,所以是可选而不是必填。
|
|
60
|
-
*/
|
|
61
|
-
const OPTIONAL_EVENT_KEYS = {
|
|
62
|
-
p2pReady: ['peerKey'],
|
|
63
|
-
p2pStatus: ['peerKey'],
|
|
64
|
-
p2pStopped: ['peerKey'],
|
|
65
|
-
};
|
|
66
|
-
|
|
67
55
|
const ADDRESS = /^tc[\x21-\x7e]{0,4095}$/;
|
|
68
56
|
const PRIVATE_KEY = /^privkey:[0-9a-f]{64}$/;
|
|
69
57
|
const CLIENT_KEY = /^nodekey:[0-9a-f]{64}$/;
|
|
@@ -161,14 +149,12 @@ function createTailcatHost(options) {
|
|
|
161
149
|
if (typeof kind !== 'string' || !EVENT_KEYS[kind]) return;
|
|
162
150
|
const keys = Object.keys(value);
|
|
163
151
|
const fields = EVENT_KEYS[kind];
|
|
164
|
-
// 已发布的旧助手只回 running:false;仅这一个空形态补齐,运行态仍须完整。
|
|
165
|
-
if (kind === 'p2pStatus' && value.running === false) {
|
|
166
|
-
value = { url: '', path: 'unknown', active: false, detail: '', candidates: [], ...value };
|
|
167
|
-
}
|
|
168
152
|
if (fields.some(field => !(field in value))) return;
|
|
169
|
-
const
|
|
170
|
-
const extra = keys.filter(key => key !== 'event' && !fields.includes(key) && !optional.includes(key));
|
|
153
|
+
const extra = keys.filter(key => key !== 'event' && !fields.includes(key));
|
|
171
154
|
if (extra.length > 0) return;
|
|
155
|
+
// 需求变为不接外部组件老形状:peerKey 现在是必填标识,缺了就丢,不猜是哪台手机。
|
|
156
|
+
if ((kind === 'p2pReady' || kind === 'p2pStatus' || kind === 'p2pStopped')
|
|
157
|
+
&& (typeof value.peerKey !== 'string' || !value.peerKey.trim())) return;
|
|
172
158
|
|
|
173
159
|
if (kind === 'ready' && typeof value.address === 'string' && (value.address === '' || ADDRESS.test(value.address))) {
|
|
174
160
|
ready = true;
|
|
@@ -292,11 +278,15 @@ function createTailcatHost(options) {
|
|
|
292
278
|
* 三个动作。
|
|
293
279
|
*/
|
|
294
280
|
startP2P(options) {
|
|
281
|
+
// 密码学桥缺私钥 / 对端公钥必须抛错,不能写空串给助手装作拉起了隧道。
|
|
282
|
+
const privateKey = typeof options.privateKey === 'string' ? options.privateKey.trim() : '';
|
|
283
|
+
const peerKey = typeof options.peerKey === 'string' ? options.peerKey.trim() : '';
|
|
284
|
+
if (!privateKey || !peerKey) throw new Error('P2P 公钥或私钥缺失,拒绝拉起隧道');
|
|
295
285
|
const list = (value) => (Array.isArray(value) ? value.filter(item => typeof item === 'string') : []);
|
|
296
286
|
write({
|
|
297
287
|
command: 'p2pStart',
|
|
298
|
-
p2pPrivateKey:
|
|
299
|
-
p2pPeerKey:
|
|
288
|
+
p2pPrivateKey: privateKey,
|
|
289
|
+
p2pPeerKey: peerKey,
|
|
300
290
|
p2pPeerLocal: list(options.peerLocal),
|
|
301
291
|
p2pPeerPublic: list(options.peerPublic),
|
|
302
292
|
p2pListenPort: Number(options.listenPort) || 0,
|
|
@@ -304,7 +294,9 @@ function createTailcatHost(options) {
|
|
|
304
294
|
});
|
|
305
295
|
},
|
|
306
296
|
stopP2P(peerKey) {
|
|
307
|
-
|
|
297
|
+
const key = typeof peerKey === 'string' ? peerKey.trim() : '';
|
|
298
|
+
if (!key) throw new Error('停止 P2P 缺少对端公钥,拒绝猜落点');
|
|
299
|
+
write({ command: 'p2pStop', p2pPeerKey: key });
|
|
308
300
|
},
|
|
309
301
|
statusP2P() {
|
|
310
302
|
write({ command: 'p2pStatus' });
|
package/lib/zeronews/account.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// 2026-11-30:需求变为不接外部组件老形状,老客户端的流量输出不再当「没有」,改报升级提示。
|
|
1
2
|
// 2026-11-29:所有 CLI 调用显式带 --workdir,普通用户读账号快照不再落到 /etc/zeronews。
|
|
2
3
|
// 只读账号快照:把 CLI 的 status / show 三张清单归一成面板能直接画的结构,不写配置、不建隧道。
|
|
3
4
|
'use strict';
|
|
@@ -293,8 +294,7 @@ function createZeroNewsAccountReader(options = {}) {
|
|
|
293
294
|
});
|
|
294
295
|
}
|
|
295
296
|
// 几张清单彼此独立,一起拉;某一张读失败就空着,不把整页带崩。
|
|
296
|
-
// 流量是 4.1.1 才有的命令,老客户端执行它只会打帮助文本、照样退 0
|
|
297
|
-
// 读不出就 traffic 为空,面板不显示这一行,别让它把「清单读失败」的提示带出来。
|
|
297
|
+
// 流量是 4.1.1 才有的命令,老客户端执行它只会打帮助文本、照样退 0。
|
|
298
298
|
const [devicesRes, tunnelsRes, domainsRes, trafficRes] = await Promise.all([
|
|
299
299
|
runJson(binary, ['show', 'devices', '--json']),
|
|
300
300
|
runJson(binary, ['show', 'tunnels', '--json']),
|
|
@@ -304,13 +304,17 @@ function createZeroNewsAccountReader(options = {}) {
|
|
|
304
304
|
const deviceItems = itemsOf(devicesRes.parsed);
|
|
305
305
|
const tunnelItems = itemsOf(tunnelsRes.parsed);
|
|
306
306
|
const domainItems = itemsOf(domainsRes.parsed);
|
|
307
|
+
// 需求变为不接外部组件老形状:流量读不出不再当「这一格没有」,明确报升级提示。
|
|
308
|
+
const traffic = normalizeTraffic(trafficRes.parsed);
|
|
309
|
+
const legacyTraffic = traffic === null;
|
|
307
310
|
const failed = [devicesRes, tunnelsRes, domainsRes].some((r) => !r.parsed);
|
|
308
311
|
return {
|
|
309
312
|
ok: true,
|
|
310
313
|
available: true,
|
|
311
314
|
login: true,
|
|
312
315
|
resourcesLoaded: !failed,
|
|
313
|
-
error: failed ? 'part of account data could not be loaded'
|
|
316
|
+
error: failed ? 'part of account data could not be loaded'
|
|
317
|
+
: (legacyTraffic ? '本机 ZeroNews 客户端版本过旧,请升级到 4.1.1 后才能读取流量用量' : ''),
|
|
314
318
|
client,
|
|
315
319
|
account,
|
|
316
320
|
counts: {
|
|
@@ -318,7 +322,7 @@ function createZeroNewsAccountReader(options = {}) {
|
|
|
318
322
|
tunnels: totalOf(tunnelsRes.parsed, tunnelItems),
|
|
319
323
|
domains: totalOf(domainsRes.parsed, domainItems),
|
|
320
324
|
},
|
|
321
|
-
traffic
|
|
325
|
+
traffic,
|
|
322
326
|
devices: compact(deviceItems.map(normalizeDevice)),
|
|
323
327
|
tunnels: compact(tunnelItems.map(normalizeTunnel)),
|
|
324
328
|
domains: compact(domainItems.map(normalizeDomain)),
|
package/lib/zeronews/probe.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// 2026-11-30:需求变为不接外部组件老形状,本地 API 只认新版 endpoints 响应字段。
|
|
1
2
|
// 从本机 ZeroNews 客户端读取「已建好的隧道公网地址」,给面板的「一键填入直连地址」用。
|
|
2
3
|
'use strict';
|
|
3
4
|
|
|
@@ -38,29 +39,29 @@ function httpsUrlOf(value) {
|
|
|
38
39
|
return url;
|
|
39
40
|
}
|
|
40
41
|
|
|
42
|
+
function legacyShapeError() {
|
|
43
|
+
return new Error('本机 ZeroNews 客户端输出的是老格式,请升级客户端到支持新版 endpoints 响应的版本');
|
|
44
|
+
}
|
|
45
|
+
|
|
41
46
|
/**
|
|
42
|
-
* 从 ZeroNews 本地 API
|
|
43
|
-
*
|
|
44
|
-
*
|
|
47
|
+
* 从 ZeroNews 本地 API 的新版响应 `{ code:200, data:{ items:[...] } }` 里挑 HTTPS 公网地址。
|
|
48
|
+
* 域名只认 `domain`。需求变为不接外部组件老形状:裸数组 / `endpoints` 别名 / `public_url`
|
|
49
|
+
* 别名一律拒绝,报「升级客户端」,不再替老工具归一。
|
|
45
50
|
*/
|
|
46
51
|
function extractEndpoints(payload) {
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
if (Array.isArray(data)
|
|
50
|
-
else if (data && Array.isArray(data.items)) items = data.items;
|
|
51
|
-
else if (data && Array.isArray(data.endpoints)) items = data.endpoints;
|
|
52
|
+
const obj = payload && typeof payload === 'object' && !Array.isArray(payload) ? payload : {};
|
|
53
|
+
const data = obj.data;
|
|
54
|
+
if (obj.code !== 200 || !data || typeof data !== 'object' || Array.isArray(data) || !Array.isArray(data.items)) throw legacyShapeError();
|
|
52
55
|
const out = [];
|
|
53
56
|
const seen = new Set();
|
|
54
|
-
for (const item of items) {
|
|
57
|
+
for (const item of data.items) {
|
|
55
58
|
if (!item || typeof item !== 'object') continue;
|
|
56
59
|
const status = String(item.status || '').toLowerCase();
|
|
57
60
|
if (status && status !== 'active') continue;
|
|
58
61
|
const type = String(item.type || '').toUpperCase();
|
|
59
62
|
if (type && type !== 'HTTPS') continue;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
: typeof item.public_url === 'string' ? item.public_url : '';
|
|
63
|
-
const url = httpsUrlOf(domain.includes('://') ? domain : `https://${domain}`);
|
|
63
|
+
if (typeof item.domain !== 'string' || !item.domain) throw legacyShapeError();
|
|
64
|
+
const url = httpsUrlOf(`https://${item.domain}`);
|
|
64
65
|
if (!url || seen.has(url)) continue;
|
|
65
66
|
seen.add(url);
|
|
66
67
|
out.push(url);
|
|
@@ -105,7 +106,14 @@ async function readZeroNewsEndpoints(options = {}) {
|
|
|
105
106
|
if (payload && typeof payload === 'object' && 'code' in payload && payload.code !== 200) {
|
|
106
107
|
return { ok: false, urls: [], available: true, error: 'ZeroNews 客户端返回了错误' };
|
|
107
108
|
}
|
|
108
|
-
|
|
109
|
+
// 只认官方新版响应;老形状直接报「升级客户端」,不替老工具归一。
|
|
110
|
+
let urls;
|
|
111
|
+
try {
|
|
112
|
+
urls = extractEndpoints(payload);
|
|
113
|
+
} catch (error) {
|
|
114
|
+
return { ok: false, urls: [], available: true, error: error && error.message ? error.message : 'ZeroNews 客户端输出老格式,请升级' };
|
|
115
|
+
}
|
|
116
|
+
return { ok: true, urls, available: true, error: '' };
|
|
109
117
|
} catch (error) {
|
|
110
118
|
if (controller && controller.signal.aborted) {
|
|
111
119
|
return { ok: false, urls: [], available: false, error: '读取本机 ZeroNews 超时,请确认客户端正在运行' };
|
package/lib/zeronews/runner.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// 2026-11-30:需求变为不接外部组件老形状,CLI status 只认新版字段,老工具报错提示升级。
|
|
1
2
|
// 2026-11-29:所有 CLI 调用显式带 --workdir(可执行文件所在目录,普通用户可写),不再落到 /etc/zeronews。
|
|
2
3
|
// 2026-11-29:本地判活走本机 healthz,不跑官方 CLI,重载窗口里 attach 的客户端静默退出也能发现。
|
|
3
4
|
// 2026-11-29:体检不再自己跑官方 CLI 查状态;面板读账号快照带来的 status 直接传进来判活。
|
|
@@ -5,7 +6,7 @@
|
|
|
5
6
|
// 2026-11-27:复用本机已在跑的客户端前比对 client_id / cloud_server_addr,另一个身份占位就明确报错不 attach。
|
|
6
7
|
// 2026-11-27:外部把隧道重建到新端口时,先用 endpoints 的落点刷新本次比对值,第一次 connect 就认下新端口。
|
|
7
8
|
// 2026-11-26:体检发现旧隧道落点端口没人监听就判失效(只改本机状态,不删不建云端隧道),交接线层清地址让兜底顶上。
|
|
8
|
-
// 2026-11-25:CLI
|
|
9
|
+
// 2026-11-25:running 认新版 CLI 的 connected,老客户端只报 running 的按老形状拒绝并提示升级。
|
|
9
10
|
// 2026-11-25:端口失配带上可识别的 reason,让接线层清掉旧地址(配对码不再带失效线路)。
|
|
10
11
|
// 2026-11-25:running 认守护进程而非早退出的启动进程;连上后可由接线层定时体检判活。
|
|
11
12
|
// 2026-11-25:复用隧道前比对 local_port,旧端口隧道不再静默复用。
|
|
@@ -148,12 +149,16 @@ function pickEndpoint(payload, expectedPort) {
|
|
|
148
149
|
*/
|
|
149
150
|
function parseStatusPayload(raw) {
|
|
150
151
|
const obj = raw && typeof raw === 'object' ? raw : {};
|
|
152
|
+
// 需求变为不接外部组件老形状:running 是老字段,新版只报 connected。
|
|
153
|
+
if ('running' in obj && !('connected' in obj)) {
|
|
154
|
+
throw legacyShapeError('本机 ZeroNews 客户端输出的是老版 status 字段(running),请升级客户端到新版后再接入');
|
|
155
|
+
}
|
|
151
156
|
const truthy = (value) => value === true || value === 'true';
|
|
152
157
|
return {
|
|
153
158
|
login: truthy(obj.login),
|
|
154
159
|
loginPending: truthy(obj.login_pending),
|
|
155
160
|
loginError: typeof obj.login_error === 'string' ? obj.login_error.trim() : '',
|
|
156
|
-
running: truthy(obj.
|
|
161
|
+
running: truthy(obj.connected),
|
|
157
162
|
configured: truthy(obj.configured),
|
|
158
163
|
clientId: typeof obj.client_id === 'string' ? obj.client_id.trim() : '',
|
|
159
164
|
node: typeof obj.cloud_server_addr === 'string' ? obj.cloud_server_addr.trim() : '',
|
|
@@ -184,6 +189,13 @@ function terminalError(message, reason) {
|
|
|
184
189
|
return error;
|
|
185
190
|
}
|
|
186
191
|
|
|
192
|
+
/** 老工具字段形状:报「升级客户端」,标 terminal 让接线层别无限重试。 */
|
|
193
|
+
function legacyShapeError(message) {
|
|
194
|
+
const error = new Error(message);
|
|
195
|
+
error.code = 'zeronews-legacy';
|
|
196
|
+
return error;
|
|
197
|
+
}
|
|
198
|
+
|
|
187
199
|
/**
|
|
188
200
|
* @param {object} options
|
|
189
201
|
* @param {() => Promise<{ok:boolean,path:string,code?:string}>} options.ensure 取二进制(provision)
|
|
@@ -288,11 +300,16 @@ function createZeroNewsRunner(options = {}) {
|
|
|
288
300
|
const start = text.indexOf('{');
|
|
289
301
|
const end = text.lastIndexOf('}');
|
|
290
302
|
if (start >= 0 && end > start) {
|
|
303
|
+
let parsed = null;
|
|
291
304
|
try {
|
|
292
|
-
|
|
305
|
+
parsed = parseStatusPayload(JSON.parse(text.slice(start, end + 1)));
|
|
306
|
+
} catch (error) {
|
|
307
|
+
if (error && error.code === 'zeronews-legacy') throw terminalError(error.message);
|
|
308
|
+
}
|
|
309
|
+
if (parsed) {
|
|
293
310
|
parsed.exitCode = result && typeof result.code === 'number' ? result.code : 0;
|
|
294
311
|
return parsed;
|
|
295
|
-
}
|
|
312
|
+
}
|
|
296
313
|
}
|
|
297
314
|
// 有些失败只把原因打在 stderr(比如 `auth client failed: client count limit ...`),没有 JSON。
|
|
298
315
|
// 认得出就把原文挂到 loginError,走上层统一翻译,别当成「没登录」去空等。
|
|
@@ -634,7 +651,11 @@ function createZeroNewsRunner(options = {}) {
|
|
|
634
651
|
if (phase !== 'connected' || aliveCheckPromise) return status();
|
|
635
652
|
const gen = generation;
|
|
636
653
|
aliveCheckPromise = (async () => {
|
|
637
|
-
|
|
654
|
+
let st = stGiven;
|
|
655
|
+
if (st === undefined) {
|
|
656
|
+
// CLI 读不到(含老格式报升级)当「不知道」,不动状态 —— 别因为一次读取失败抖掉还能用的线路。
|
|
657
|
+
try { st = await cliStatus(); } catch { return; }
|
|
658
|
+
}
|
|
638
659
|
if (gen !== generation || phase !== 'connected' || !st) return;
|
|
639
660
|
daemonRunning = st.running === true;
|
|
640
661
|
await applyLiveness(gen);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-mobile-plugin",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.145",
|
|
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,23 @@
|
|
|
117
117
|
"yaml": "2.9.1"
|
|
118
118
|
},
|
|
119
119
|
"dshMobileReleaseNotes": {
|
|
120
|
-
"version": "0.5.
|
|
120
|
+
"version": "0.5.145",
|
|
121
121
|
"kinds": [
|
|
122
|
+
"feature",
|
|
122
123
|
"fix"
|
|
123
124
|
],
|
|
124
125
|
"notes": {
|
|
125
|
-
"zh-Hans": "-
|
|
126
|
-
"zh-Hant": "-
|
|
127
|
-
"en": "-
|
|
128
|
-
"ja": "-
|
|
129
|
-
"ko": "-
|
|
130
|
-
"de": "-
|
|
131
|
-
"es": "-
|
|
132
|
-
"fr": "-
|
|
133
|
-
"pt": "-
|
|
134
|
-
"ru": "-
|
|
135
|
-
"tr": "-
|
|
126
|
+
"zh-Hans": "- 主配对卡的二维码弹窗新增内容勾选,可自选二维码里包含哪些线路;默认全选。\n- 新增局域网发现开关(默认开启):关掉后不再在局域网广播,但局域网连接、配对和二维码照常。\n- 设备详情里能看到这台手机最后一次真实操作的时间。\n- 修复插件更新换代后 Cloudflare 兜底隧道可能没有自动起来、手机连不上的问题。\n- 面板「国际」线路新增「我的账号」入口,可以用自己的 Cloudflare 账号做固定域名的命名隧道。",
|
|
127
|
+
"zh-Hant": "- 主配對卡的二維碼彈窗新增內容勾選,可自選二維碼裡包含哪些線路;預設全選。\n- 新增區域網路探索開關(預設開啟):關掉後不再在區域網路廣播,但區域網路連線、配對和二維碼照常。\n- 裝置詳情裡能看到這台手機最後一次真實操作的時間。\n- 修正外掛更新換代後 Cloudflare 備援隧道可能沒有自動起來、手機連不上的問題。\n- 面板「國際」線路新增「我的帳號」入口,可以用自己的 Cloudflare 帳號做固定網域的命名隧道。",
|
|
128
|
+
"en": "- The QR dialog on the main pairing card now has content checkboxes, so you can choose which routes the QR code includes; all are selected by default.\n- New LAN discovery switch (on by default): turn it off to stop broadcasting on the local network, while LAN connections, pairing and the QR code keep working.\n- Device details now show the last time this phone actually performed an action.\n- Fixed an issue where, after a plugin update swapped generations, the Cloudflare fallback tunnel might not start automatically and the phone could not connect.\n- The international panel now has a \"My account\" entry, so you can set up a Cloudflare named tunnel with a fixed domain on your own account.",
|
|
129
|
+
"ja": "- メインのペアリングカードの QR コードダイアログに内容のチェック項目を追加し、QR コードに含める回線を選べるようにしました。既定ではすべて選択されています。\n- ローカルネットワーク検出のスイッチを追加しました(既定はオン)。オフにするとローカルネットワークへのブロードキャストを停止しますが、LAN 接続・ペアリング・QR コードはそのまま使えます。\n- 端末の詳細で、このスマートフォンが最後に実際に操作した時刻を確認できるようにしました。\n- プラグイン更新で世代が切り替わった後、Cloudflare のフォールバックトンネルが自動で起動せずスマートフォンから接続できないことがある問題を修正しました。\n- パネルの「国際」回線に「マイアカウント」の入口を追加し、自分の Cloudflare アカウントで固定ドメインの名前付きトンネルを設定できるようにしました。",
|
|
130
|
+
"ko": "- 기본 페어링 카드의 QR 코드 대화상자에 포함 항목 체크박스를 추가해 QR 코드에 어떤 회선을 넣을지 고를 수 있습니다. 기본값은 모두 선택입니다.\n- 로컬 네트워크 검색 스위치를 추가했습니다(기본 켜짐). 끄면 로컬 네트워크 브로드캐스트를 멈추지만 LAN 연결, 페어링, QR 코드는 그대로 동작합니다.\n- 기기 상세에서 이 휴대폰이 마지막으로 실제 조작한 시간을 볼 수 있습니다.\n- 플러그인 업데이트로 세대가 교체된 뒤 Cloudflare 대체 터널이 자동으로 시작되지 않아 휴대폰이 연결되지 않을 수 있던 문제를 수정했습니다.\n- 패널의 \"국제\" 회선에 \"내 계정\" 진입점을 추가해, 내 Cloudflare 계정으로 고정 도메인의 명명된 터널을 설정할 수 있습니다.",
|
|
131
|
+
"de": "- Der QR-Dialog der Haupt-Kopplungskarte hat jetzt Kontrollkästchen, mit denen Sie wählen können, welche Routen der QR-Code enthält; standardmäßig sind alle ausgewählt.\n- Neuer Schalter für die LAN-Erkennung (standardmäßig an): Ausgeschaltet stoppt er die Übertragung im lokalen Netz, während LAN-Verbindungen, Kopplung und QR-Code weiter funktionieren.\n- In den Gerätedetails wird jetzt angezeigt, wann dieses Telefon zuletzt tatsächlich eine Aktion ausgeführt hat.\n- Ein Problem wurde behoben, bei dem nach einem Plugin-Update mit Generationswechsel der Cloudflare-Fallback-Tunnel möglicherweise nicht automatisch startete und das Telefon keine Verbindung bekam.\n- Das internationale Panel hat jetzt einen Eintrag „Mein Konto“, mit dem Sie mit Ihrem eigenen Cloudflare-Konto einen benannten Tunnel mit fester Domain einrichten können.",
|
|
132
|
+
"es": "- El diálogo del código QR de la tarjeta de emparejamiento principal ahora tiene casillas de contenido, para elegir qué rutas incluye el código; por defecto están todas marcadas.\n- Nuevo interruptor de detección de red local (activado por defecto): al desactivarlo se deja de emitir en la red local, mientras que las conexiones LAN, el emparejamiento y el código QR siguen funcionando.\n- Los detalles del dispositivo ahora muestran cuándo fue la última vez que este teléfono realizó realmente una acción.\n- Se corrigió un problema por el que, tras un cambio de generación al actualizar el plugin, el túnel de respaldo de Cloudflare podía no iniciarse solo y el teléfono no podía conectarse.\n- El panel internacional ahora tiene una entrada «Mi cuenta», para configurar un túnel con nombre y dominio fijo con tu propia cuenta de Cloudflare.",
|
|
133
|
+
"fr": "- La boîte de dialogue du QR code de la carte d'appairage principale propose désormais des cases de contenu, pour choisir les itinéraires inclus dans le QR code ; toutes sont cochées par défaut.\n- Nouvel interrupteur de détection du réseau local (activé par défaut) : une fois désactivé, la diffusion sur le réseau local s'arrête, tandis que les connexions LAN, l'appairage et le QR code continuent de fonctionner.\n- Les détails de l'appareil indiquent désormais la dernière fois que ce téléphone a réellement effectué une action.\n- Correction d'un problème où, après un changement de génération lors d'une mise à jour du plugin, le tunnel de secours Cloudflare pouvait ne pas démarrer automatiquement et le téléphone ne pas se connecter.\n- Le panneau international dispose maintenant d'une entrée « Mon compte », pour configurer un tunnel nommé à domaine fixe avec votre propre compte Cloudflare.",
|
|
134
|
+
"pt": "- A janela do código QR do cartão de emparelhamento principal agora tem caixas de conteúdo, para escolher quais rotas o código inclui; por padrão, todas ficam marcadas.\n- Novo interruptor de descoberta de rede local (ligado por padrão): ao desligá-lo, para de transmitir na rede local, enquanto as conexões LAN, o emparelhamento e o código QR continuam funcionando.\n- Os detalhes do dispositivo agora mostram quando este telefone realizou uma ação pela última vez.\n- Corrigido um problema em que, após a troca de geração numa atualização do plugin, o túnel de reserva do Cloudflare podia não iniciar sozinho e o telefone não conseguia conectar.\n- O painel internacional agora tem uma entrada «Minha conta», para configurar um túnel nomeado com domínio fixo usando sua própria conta Cloudflare.",
|
|
135
|
+
"ru": "- В диалоге QR-кода основной карточки сопряжения появились флажки содержимого: можно выбрать, какие маршруты войдут в QR-код; по умолчанию выбраны все.\n- Добавлен переключатель обнаружения в локальной сети (по умолчанию включён): при выключении трансляция в локальной сети прекращается, а подключения по LAN, сопряжение и QR-код продолжают работать.\n- В сведениях об устройстве теперь видно, когда этот телефон последний раз действительно выполнял действие.\n- Исправлена проблема, из-за которой после смены поколения при обновлении плагина резервный туннель Cloudflare мог не запускаться автоматически, и телефон не мог подключиться.\n- На международной панели появился вход «Мой аккаунт», позволяющий настроить именованный туннель с постоянным доменом на своём аккаунте Cloudflare.",
|
|
136
|
+
"tr": "- Ana eşleştirme kartındaki QR kodu penceresine içerik onay kutuları eklendi; QR kodunun hangi hatları içereceğini seçebilirsiniz, varsayılan olarak hepsi işaretlidir.\n- Yeni yerel ağ keşif anahtarı (varsayılan açık): kapatıldığında yerel ağda yayın durur, ancak LAN bağlantıları, eşleştirme ve QR kodu çalışmaya devam eder.\n- Cihaz ayrıntılarında bu telefonun en son gerçekte ne zaman işlem yaptığı görülebilir.\n- Eklenti güncellemesinde nesil değişiminden sonra Cloudflare yedek tünelinin otomatik başlamayabileceği ve telefonun bağlanamayabileceği bir sorun giderildi.\n- Panelin \"Uluslararası\" hattına \"Hesabım\" girişi eklendi; kendi Cloudflare hesabınızla sabit alan adlı adlandırılmış bir tünel kurabilirsiniz."
|
|
136
137
|
}
|
|
137
138
|
}
|
|
138
139
|
}
|