dsh-mobile-plugin 0.5.132 → 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/mobile/git.js +10 -2
- package/lib/relay/lan-network.cjs +36 -7
- package/package.json +15 -14
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,3 +1,4 @@
|
|
|
1
|
+
// 反馈 1569:插件跑在容器里时容器内网 eth0 不进局域网候选(按容器标记判,不按 172 地址段)。
|
|
1
2
|
// 反馈 1012:172.17/16 是真实 Wi-Fi 可用的私网段,容器 / 虚拟网卡改由网卡名黑名单挡。
|
|
2
3
|
// 反馈 1562:节点小宝 NodeBabyLink 是第三方穿透 VPN 虚拟网卡,按网卡名挡,不进局域网候选。
|
|
3
4
|
// 没有已监听端口时不产出可连接候选。
|
|
@@ -12,6 +13,7 @@
|
|
|
12
13
|
*/
|
|
13
14
|
'use strict'
|
|
14
15
|
|
|
16
|
+
const fsSync = require('node:fs')
|
|
15
17
|
const os = require('node:os')
|
|
16
18
|
// 私有地址判断搬到 shared/private-address.js:内核也要用它,不能反过来让内核依赖这个会频繁变的文件。
|
|
17
19
|
const { isPrivateLanAddress } = require('../shared/private-address.js')
|
|
@@ -148,14 +150,19 @@ function toCandidates(list, port, family = 'IPv4') {
|
|
|
148
150
|
// Structured view of the usable LAN endpoints. The app's `candidateUrls()` accepts
|
|
149
151
|
// this shape, so callers that want interface metadata (for diagnostics or smarter
|
|
150
152
|
// ordering) should prefer it.
|
|
151
|
-
|
|
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 []
|
|
152
159
|
return toCandidates(collectEndpoints(interfaces, isLanCandidateAddress), port)
|
|
153
160
|
}
|
|
154
|
-
function lanUrls(port, interfaces = os.networkInterfaces()) {
|
|
155
|
-
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)
|
|
156
163
|
}
|
|
157
|
-
function lanCandidates(port, interfaces = os.networkInterfaces()) {
|
|
158
|
-
return lanInterfaces(port, interfaces)
|
|
164
|
+
function lanCandidates(port, interfaces = os.networkInterfaces(), opts = {}) {
|
|
165
|
+
return lanInterfaces(port, interfaces, opts)
|
|
159
166
|
}
|
|
160
167
|
|
|
161
168
|
/**
|
|
@@ -307,6 +314,27 @@ function ipv6Candidates(port, interfaces = os.networkInterfaces()) {
|
|
|
307
314
|
}
|
|
308
315
|
}
|
|
309
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
|
+
|
|
310
338
|
/**
|
|
311
339
|
* 对外公布的候选地址:**先私网,一个都没有时才退到公网**。
|
|
312
340
|
*
|
|
@@ -317,9 +345,9 @@ function ipv6Candidates(port, interfaces = os.networkInterfaces()) {
|
|
|
317
345
|
* 取不到网卡(异常)时回空清单、绝不抛:它喂的是二维码与移动端的连接信息,
|
|
318
346
|
* 让它把整条控制面拖下水不值得。
|
|
319
347
|
*/
|
|
320
|
-
function advertisedCandidates(port, interfaces = os.networkInterfaces()) {
|
|
348
|
+
function advertisedCandidates(port, interfaces = os.networkInterfaces(), opts = {}) {
|
|
321
349
|
try {
|
|
322
|
-
const lan = lanCandidates(port, interfaces)
|
|
350
|
+
const lan = lanCandidates(port, interfaces, opts)
|
|
323
351
|
if (lan.length > 0) return lan
|
|
324
352
|
return publicCandidates(port, interfaces)
|
|
325
353
|
} catch {
|
|
@@ -508,6 +536,7 @@ module.exports = {
|
|
|
508
536
|
isVpnInterface,
|
|
509
537
|
isVirtualInterface,
|
|
510
538
|
interfaceRank,
|
|
539
|
+
isContainerRuntime,
|
|
511
540
|
lanInterfaces,
|
|
512
541
|
lanUrls,
|
|
513
542
|
lanCandidates,
|
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,22 +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
|
-
"fix"
|
|
122
|
+
"fix",
|
|
123
|
+
"feature"
|
|
123
124
|
],
|
|
124
125
|
"notes": {
|
|
125
|
-
"zh-Hans": "-
|
|
126
|
-
"zh-Hant": "-
|
|
127
|
-
"en": "- When
|
|
128
|
-
"ja": "-
|
|
129
|
-
"ko": "-
|
|
130
|
-
"de": "- Wenn
|
|
131
|
-
"es": "- Cuando
|
|
132
|
-
"fr": "-
|
|
133
|
-
"pt": "- Quando
|
|
134
|
-
"ru": "-
|
|
135
|
-
"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."
|
|
136
137
|
}
|
|
137
138
|
}
|
|
138
139
|
}
|