dsh-mobile-plugin 0.5.131 → 0.5.133
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/cloudflared/wiring.cjs +4 -0
- package/lib/impl.js +5 -1
- package/lib/mobile/git.js +10 -2
- package/lib/relay/lan-network.cjs +38 -8
- package/lib/relay/lan-proxy.js +7 -1
- package/package.json +15 -15
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// 2026-11-28:回环遮蔽判定落地时,正在跑的兜底隧道也要重指落点(issue #45);此前判定后只重判启停、不纠偏已起隧道的落点,公网一直指到被占的旧端口。
|
|
1
2
|
// 2026-11-25:自动兜底只在「需要绕开且没有可用公网线路」时启用;先备份再收起手填直连地址,停掉后原样还原。
|
|
2
3
|
// Cloudflare 兜底隧道接线:runner 创建、地址回报(写独立字段 cloudflareUrl)、过期地址撤回、自动启动与启停包装。
|
|
3
4
|
'use strict';
|
|
@@ -134,6 +135,9 @@ function mountCloudflare(options) {
|
|
|
134
135
|
if (!fallbackOn) { await rememberManual(); fallbackOn = true; }
|
|
135
136
|
const now = status();
|
|
136
137
|
if (!now.running && !now.starting) await start();
|
|
138
|
+
// 判定落地后纠偏落点:隧道可能在回环判定出来之前就按 lanPort 起了,此时专属入口已就绪,
|
|
139
|
+
// 但进程仍指着被遮蔽的旧端口。syncLocalPort 幂等,端口没变就不会真重启。
|
|
140
|
+
else if (now.running) await syncLocalPort();
|
|
137
141
|
} else if (fallbackOn) {
|
|
138
142
|
fallbackOn = false;
|
|
139
143
|
await stop();
|
package/lib/impl.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// 2026-11-28:移动端直连候选统一在装配层兑现「手机优先用这条」,连接信息 / 配对 / 概况同口径。
|
|
1
2
|
// 2026-11-27:线路级问题码搬进 relay/ingress-guard.cjs,装配层只交现状、不再写判断。
|
|
2
3
|
// 2026-11-26:零讯旧隧道落点端口失效时接线层清掉地址,通知 Cloudflare 兜底重新判定顶上。
|
|
3
4
|
// 2026-11-25:三条线路的本地端口接上回环入口判据;自检结论记入 ingress-guard,状态带出绕开与兜底原因。
|
|
@@ -804,7 +805,10 @@ function apply(ctx) {
|
|
|
804
805
|
// 连接信息永远停在进程启动那一刻。
|
|
805
806
|
getSidecarSnapshot: sidecarLifecycle.getSnapshot,
|
|
806
807
|
// 移动端那边的「局域网候选」:私网优先的清单 + 用户手填的直连地址(网卡扫不出的域名)。
|
|
807
|
-
|
|
808
|
+
// 重排也在这一层兑现:连接信息 / 配对回包 / 同步概况都拿这份,少了 preferred 那半句就
|
|
809
|
+
// 只有 /connection-info 自己套的那层有效,配对回包与概况仍是未重排清单。只挪顺序、不删候选,
|
|
810
|
+
// 手填的那条照旧缀在最后(见 lan-network.cjs 的 orderCandidates / withManualCandidate)。
|
|
811
|
+
safeLanCandidates: (port) => phoneCandidates(advertisedCandidates(port), { preferred: state.preferredLanAddress, manual: state.manualLanUrl }),
|
|
808
812
|
// IPv6 直连候选单独一份:App 拿它单开一条通道、和公网中转比速度,不掺进上面那份的排序。
|
|
809
813
|
// 手填的那条同样缀在最后(只追加、不删网卡候选),手机每次核对连接信息都重新拿到它。
|
|
810
814
|
safeIpv6Candidates: (port) => withManualIpv6Candidate(ipv6Candidates(port), state.manualIpv6Url),
|
package/lib/mobile/git.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// 本次改动:给手机上会显示的中文错误补稳定机器码(JSON 请求体单独成码),中文只做日志兜底。
|
|
2
|
+
// 本次改动:仓库摘要一并回传宿主已识别的仓库清单,手机端据此切换仓库。
|
|
2
3
|
'use strict';
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -151,7 +152,7 @@ async function resolveTarget(ctx, params) {
|
|
|
151
152
|
if (!marker.repos.some((repo) => repo.root === repoRoot)) {
|
|
152
153
|
throw fail('FORBIDDEN', '这个仓库不在该项目的识别结果里');
|
|
153
154
|
}
|
|
154
|
-
return { projectPath, repoRoot };
|
|
155
|
+
return { projectPath, repoRoot, marker };
|
|
155
156
|
}
|
|
156
157
|
|
|
157
158
|
/** HEAD 是否存在:空仓库(还没有第一个提交)时很多命令的行为不一样。 */
|
|
@@ -205,7 +206,14 @@ async function handleGitRepo(ctx, req, res) {
|
|
|
205
206
|
workspaceId: params.get('workspaceId'),
|
|
206
207
|
repo: params.get('repo'),
|
|
207
208
|
});
|
|
208
|
-
|
|
209
|
+
// 仓库清单是识别层已经算好的(同一份也用来校验 repo 参数):跟着摘要一起回,
|
|
210
|
+
// 手机端才有得切。工作区清单继续保持精简,不为每个条目都带这份数组。
|
|
211
|
+
sendJson(res, 200, {
|
|
212
|
+
ok: true,
|
|
213
|
+
...(await read.repoOf(target.repoRoot)),
|
|
214
|
+
repos: target.marker.repos,
|
|
215
|
+
truncated: target.marker.truncated,
|
|
216
|
+
});
|
|
209
217
|
}
|
|
210
218
|
|
|
211
219
|
/** GET git/status:四个分组,带每个文件的增删与二进制标记。 */
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
// 反馈 1569:插件跑在容器里时容器内网 eth0 不进局域网候选(按容器标记判,不按 172 地址段)。
|
|
1
2
|
// 反馈 1012:172.17/16 是真实 Wi-Fi 可用的私网段,容器 / 虚拟网卡改由网卡名黑名单挡。
|
|
3
|
+
// 反馈 1562:节点小宝 NodeBabyLink 是第三方穿透 VPN 虚拟网卡,按网卡名挡,不进局域网候选。
|
|
2
4
|
// 没有已监听端口时不产出可连接候选。
|
|
3
5
|
/**
|
|
4
6
|
* 网卡枚举与候选地址:私网 / 公网 / IPv6 全球单播三份清单,外加「用户选中的那条排最前」。
|
|
@@ -11,6 +13,7 @@
|
|
|
11
13
|
*/
|
|
12
14
|
'use strict'
|
|
13
15
|
|
|
16
|
+
const fsSync = require('node:fs')
|
|
14
17
|
const os = require('node:os')
|
|
15
18
|
// 私有地址判断搬到 shared/private-address.js:内核也要用它,不能反过来让内核依赖这个会频繁变的文件。
|
|
16
19
|
const { isPrivateLanAddress } = require('../shared/private-address.js')
|
|
@@ -50,7 +53,7 @@ function isLanCandidateAddress(address) {
|
|
|
50
53
|
}
|
|
51
54
|
|
|
52
55
|
function isVpnInterface(name) {
|
|
53
|
-
return /^(?:utun|tun|tap|ppp|ipsec|wg|tailscale|vpn|zt|nebula)/i.test(String(name))
|
|
56
|
+
return /^(?:utun|tun|tap|ppp|ipsec|wg|tailscale|vpn|zt|nebula|nodebaby)/i.test(String(name))
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
// Interfaces that routinely hold an RFC1918 address but are NOT reachable from a
|
|
@@ -147,14 +150,19 @@ function toCandidates(list, port, family = 'IPv4') {
|
|
|
147
150
|
// Structured view of the usable LAN endpoints. The app's `candidateUrls()` accepts
|
|
148
151
|
// this shape, so callers that want interface metadata (for diagnostics or smarter
|
|
149
152
|
// ordering) should prefer it.
|
|
150
|
-
|
|
153
|
+
// `opts.inContainer` 只给测试注入容器现场;生产走 isContainerRuntime() 的只读探测。
|
|
154
|
+
function lanInterfaces(port, interfaces = os.networkInterfaces(), opts = {}) {
|
|
155
|
+
const inContainer = typeof opts.inContainer === 'boolean' ? opts.inContainer : isContainerRuntime()
|
|
156
|
+
// 容器里那块 eth0 是容器内网、手机拨不进来;整条私网清单不产出,二维码与 /connection-info
|
|
157
|
+
// 转而走公网候选 + 手填地址。不动 isLanCandidateAddress 的地址段判据(172.x 真实 Wi-Fi 照旧)。
|
|
158
|
+
if (inContainer) return []
|
|
151
159
|
return toCandidates(collectEndpoints(interfaces, isLanCandidateAddress), port)
|
|
152
160
|
}
|
|
153
|
-
function lanUrls(port, interfaces = os.networkInterfaces()) {
|
|
154
|
-
return lanInterfaces(port, interfaces).map((candidate) => candidate.url)
|
|
161
|
+
function lanUrls(port, interfaces = os.networkInterfaces(), opts = {}) {
|
|
162
|
+
return lanInterfaces(port, interfaces, opts).map((candidate) => candidate.url)
|
|
155
163
|
}
|
|
156
|
-
function lanCandidates(port, interfaces = os.networkInterfaces()) {
|
|
157
|
-
return lanInterfaces(port, interfaces)
|
|
164
|
+
function lanCandidates(port, interfaces = os.networkInterfaces(), opts = {}) {
|
|
165
|
+
return lanInterfaces(port, interfaces, opts)
|
|
158
166
|
}
|
|
159
167
|
|
|
160
168
|
/**
|
|
@@ -306,6 +314,27 @@ function ipv6Candidates(port, interfaces = os.networkInterfaces()) {
|
|
|
306
314
|
}
|
|
307
315
|
}
|
|
308
316
|
|
|
317
|
+
// 反馈 1569:插件自己跑在容器里时,os.networkInterfaces() 只有 lo + eth0(容器内网地址),
|
|
318
|
+
// 手机永远拨不进来。这里按「进程是不是在容器里」判,而不是按地址段 —— 172.x 可能是真实
|
|
319
|
+
// Wi-Fi(反馈 1012 已拍板),不能因为地址落在私网段就排除。容器标记都是只读文件,读不到
|
|
320
|
+
// 一律当不在容器;结果按进程缓存,容器身份在进程生命周期内不会变。
|
|
321
|
+
let containerHint
|
|
322
|
+
function isContainerRuntime() {
|
|
323
|
+
if (containerHint !== undefined) return containerHint
|
|
324
|
+
let hit = false
|
|
325
|
+
try {
|
|
326
|
+
for (const marker of ['/.dockerenv', '/run/.containerenv']) {
|
|
327
|
+
if (fsSync.existsSync(marker)) { hit = true; break }
|
|
328
|
+
}
|
|
329
|
+
if (!hit) {
|
|
330
|
+
const cgroup = fsSync.readFileSync('/proc/1/cgroup', 'utf8')
|
|
331
|
+
hit = /(?:docker|containerd|kubepods|lxc[/])/.test(cgroup)
|
|
332
|
+
}
|
|
333
|
+
} catch { /* 非 Linux / 读不到标记:当不在容器 */ }
|
|
334
|
+
containerHint = hit
|
|
335
|
+
return hit
|
|
336
|
+
}
|
|
337
|
+
|
|
309
338
|
/**
|
|
310
339
|
* 对外公布的候选地址:**先私网,一个都没有时才退到公网**。
|
|
311
340
|
*
|
|
@@ -316,9 +345,9 @@ function ipv6Candidates(port, interfaces = os.networkInterfaces()) {
|
|
|
316
345
|
* 取不到网卡(异常)时回空清单、绝不抛:它喂的是二维码与移动端的连接信息,
|
|
317
346
|
* 让它把整条控制面拖下水不值得。
|
|
318
347
|
*/
|
|
319
|
-
function advertisedCandidates(port, interfaces = os.networkInterfaces()) {
|
|
348
|
+
function advertisedCandidates(port, interfaces = os.networkInterfaces(), opts = {}) {
|
|
320
349
|
try {
|
|
321
|
-
const lan = lanCandidates(port, interfaces)
|
|
350
|
+
const lan = lanCandidates(port, interfaces, opts)
|
|
322
351
|
if (lan.length > 0) return lan
|
|
323
352
|
return publicCandidates(port, interfaces)
|
|
324
353
|
} catch {
|
|
@@ -507,6 +536,7 @@ module.exports = {
|
|
|
507
536
|
isVpnInterface,
|
|
508
537
|
isVirtualInterface,
|
|
509
538
|
interfaceRank,
|
|
539
|
+
isContainerRuntime,
|
|
510
540
|
lanInterfaces,
|
|
511
541
|
lanUrls,
|
|
512
542
|
lanCandidates,
|
package/lib/relay/lan-proxy.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// 2026-11-28:回环来源的通道标注从 lan 改记 tunnel,第三方穿透不再显示成「局域网」。
|
|
1
2
|
// 2026-11-25:多开一条只听 127.0.0.1 的专属入口,与主入口共用 handleRequest;被占则内核另分一次并报上去。
|
|
2
3
|
// 代理已授权移动请求,独立绑定双栈监听并透传 mux 手机端存活证明。
|
|
3
4
|
'use strict';
|
|
@@ -114,7 +115,7 @@ function createLanProxy(opts) {
|
|
|
114
115
|
const manualDirectHost = (() => {
|
|
115
116
|
try { return manualLanUrl ? new URL(manualLanUrl).hostname.toLowerCase() : '' } catch { return '' }
|
|
116
117
|
})();
|
|
117
|
-
/** 这条请求实际从哪条通道来:命中手填直连的 Host 记 direct,否则按监听族分 ipv6 / lan。 */
|
|
118
|
+
/** 这条请求实际从哪条通道来:命中手填直连的 Host 记 direct,回环来源记 tunnel,否则按监听族分 ipv6 / lan。 */
|
|
118
119
|
const channelFor = (req) => {
|
|
119
120
|
if (manualDirectHost) {
|
|
120
121
|
const host = String(req?.headers?.host || '').trim();
|
|
@@ -124,6 +125,11 @@ function createLanProxy(opts) {
|
|
|
124
125
|
} catch { /* 非法 Host 当没命中 */ }
|
|
125
126
|
}
|
|
126
127
|
}
|
|
128
|
+
// 反馈 1562:第三方穿透(节点小宝等)从回环把流量转进本代理,本机监听是 IPv4、
|
|
129
|
+
// Host 又不命中手填域名,旧判据会记成 lan,把「外网穿透」在设备列表里显示成「局域网」。
|
|
130
|
+
// 回环来源一律记 tunnel(白名单内、面板有文案、控制面只看标记非空),不冒充局域网。
|
|
131
|
+
const remote = String(req?.socket?.remoteAddress || '').toLowerCase();
|
|
132
|
+
if (remote === '127.0.0.1' || remote === '::1' || remote === '::ffff:127.0.0.1') return 'tunnel';
|
|
127
133
|
return req?.socket?.localFamily === 'IPv6' ? 'ipv6' : 'lan';
|
|
128
134
|
};
|
|
129
135
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-mobile-plugin",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.133",
|
|
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.133",
|
|
121
121
|
"kinds": [
|
|
122
|
-
"
|
|
123
|
-
"
|
|
122
|
+
"fix",
|
|
123
|
+
"feature"
|
|
124
124
|
],
|
|
125
125
|
"notes": {
|
|
126
|
-
"zh-Hans": "-
|
|
127
|
-
"zh-Hant": "-
|
|
128
|
-
"en": "-
|
|
129
|
-
"ja": "-
|
|
130
|
-
"ko": "-
|
|
131
|
-
"de": "-
|
|
132
|
-
"es": "-
|
|
133
|
-
"fr": "-
|
|
134
|
-
"pt": "-
|
|
135
|
-
"ru": "-
|
|
136
|
-
"tr": "-
|
|
126
|
+
"zh-Hans": "- 插件跑在容器里时,配对二维码不再给出拨不通的容器内网地址,改用公网候选或手填地址。\n- 仓库摘要现在带出项目里的全部仓库根,手机上可以切换到并列仓库、子模块和工作树。",
|
|
127
|
+
"zh-Hant": "- 外掛在容器裡執行時,配對二維碼不再給出連不上的容器內網位址,改採公網候選或手填位址。\n- 倉庫摘要現在帶出專案裡的全部倉庫根,手機上可以切換到並列倉庫、子模組與工作樹。",
|
|
128
|
+
"en": "- When the plugin runs inside a container, the pairing QR code no longer leads with an unreachable container-internal address; it falls back to public candidates or a manually entered address.\n- The repository summary now includes every repository root in the project, so you can switch to sibling repositories, submodules, and worktrees on your phone.",
|
|
129
|
+
"ja": "- プラグインがコンテナ内で動いている場合、ペアリング用QRコードに接続できないコンテナ内網アドレスが表示されなくなり、公開アドレス候補または手入力アドレスに切り替わります。\n- リポジトリの概要にプロジェクト内のすべてのリポジトリルートが含まれるようになり、スマートフォンで並列リポジトリ、サブモジュール、ワークツリーに切り替えられます。",
|
|
130
|
+
"ko": "- 플러그인이 컨테이너 안에서 실행될 때, 페어링 QR 코드에 연결할 수 없는 컨테이너 내부 주소가 더 이상 표시되지 않고 공개 후보 주소나 직접 입력한 주소를 사용합니다.\n- 저장소 요약에 프로젝트의 모든 저장소 루트가 포함되어, 휴대폰에서 나란한 저장소, 서브모듈, 워크트리로 전환할 수 있습니다.",
|
|
131
|
+
"de": "- Wenn das Plugin in einem Container läuft, zeigt der Pairing-QR-Code keine nicht erreichbaren Container-internen Adressen mehr an, sondern greift auf öffentliche Kandidaten oder eine manuell eingegebene Adresse zurück.\n- Die Repository-Übersicht enthält jetzt alle Repository-Wurzeln im Projekt, damit Sie auf dem Telefon zu parallelen Repositories, Submodulen und Worktrees wechseln können.",
|
|
132
|
+
"es": "- Cuando el plugin se ejecuta dentro de un contenedor, el código QR de emparejamiento ya no muestra direcciones internas del contenedor a las que no se puede conectar; usa candidatos públicos o una dirección introducida manualmente.\n- El resumen del repositorio ahora incluye todas las raíces de repositorios del proyecto, para que puedas cambiar a repositorios paralelos, submódulos y worktrees desde el teléfono.",
|
|
133
|
+
"fr": "- Lorsque le plugin s'exécute dans un conteneur, le code QR d'appariement n'affiche plus d'adresses internes du conteneur inaccessibles ; il repasse sur les candidats publics ou une adresse saisie manuellement.\n- Le résumé du dépôt inclut désormais toutes les racines de dépôts du projet, afin de pouvoir basculer vers les dépôts parallèles, les sous-modules et les worktrees depuis le téléphone.",
|
|
134
|
+
"pt": "- Quando o plugin corre dentro de um contentor, o código QR de emparelhamento deixa de mostrar endereços internos do contentor inacessíveis e passa a usar candidatos públicos ou um endereço introduzido manualmente.\n- O resumo do repositório agora inclui todas as raízes de repositórios do projeto, para que possa mudar para repositórios paralelos, submódulos e worktrees no telemóvel.",
|
|
135
|
+
"ru": "- Когда плагин работает внутри контейнера, QR-код сопряжения больше не показывает недоступные внутренние адреса контейнера и использует публичные кандидаты или введённый вручную адрес.\n- Сводка репозитория теперь включает все корни репозиториев проекта, чтобы на телефоне можно было переключаться на параллельные репозитории, подмодули и рабочие копии.",
|
|
136
|
+
"tr": "- Eklenti bir konteyner içinde çalıştığında, eşleştirme QR kodu artık erişilemeyen konteyner içi adresleri göstermiyor; genel adaylara veya elle girilen bir adrese geçiyor.\n- Depo özeti artık projedeki tüm depo köklerini içeriyor; böylece telefondan yan depolara, alt modüllere ve worktree'lere geçebilirsiniz."
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
}
|