dsh-plugin-reverse-proxy 0.0.0-stage → 0.3.5

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 CHANGED
@@ -1,3 +1,275 @@
1
- # Temporary Holding Version
1
+ <p align="center">
2
+ <img src="assets/logo.jpg" width="132" alt="大肥鱼">
3
+ </p>
2
4
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
5
+ <h1 align="center">dsh-plugin-reverse-proxy</h1>
6
+
7
+ <p align="center">简体中文 | <a href="README.en.md">English</a></p>
8
+
9
+ <p align="center">
10
+ <a href="#"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="license"></a>
11
+ <a href="#"><img src="https://img.shields.io/badge/dependencies-0-brightgreen.svg" alt="dependencies"></a>
12
+ <a href="#"><img src="https://img.shields.io/badge/build-none-brightgreen.svg" alt="build"></a>
13
+ <a href="#"><img src="https://img.shields.io/badge/dsh-0.2.2--rc.3-blueviolet.svg" alt="dsh"></a>
14
+ <a href="#"><img src="https://img.shields.io/badge/status-beta-orange.svg" alt="status"></a>
15
+ <a href="https://github.com/llifco/dsh-plugin-reverse-proxy/releases/latest"><img src="https://img.shields.io/github/v/release/llifco/dsh-plugin-reverse-proxy?label=release" alt="release"></a>
16
+ <a href="https://github.com/llifco/dsh-plugin-reverse-proxy/stargazers"><img src="https://img.shields.io/github/stars/llifco/dsh-plugin-reverse-proxy" alt="stars"></a>
17
+ </p>
18
+
19
+ > 一条命令装上,局域网里的手机、平板、另一台电脑就能直接打开你的 DSH 网页界面,
20
+ > **而且不用再从启动日志里抄那串随机 token**。
21
+
22
+ ---
23
+
24
+ ## 三个能力
25
+
26
+ > 0.3.5 起:设置页开关换成紫色,**监听端口**也能自己填了(默认 8080,保存即生效,重启保留)。
27
+
28
+ ### 1. 反向代理(默认启用)
29
+
30
+ ```
31
+ 局域网浏览器 ──▶ 0.0.0.0:8080 (本插件,开关开启后才会监听;端口可改)
32
+ │ 改写请求头:
33
+ │ Host → 127.0.0.1:3080
34
+ │ Origin → http://127.0.0.1:3080
35
+ │ Sec-Fetch-Site → same-origin
36
+ │ Referer → 清空
37
+ │ 补充:X-Real-IP / X-Forwarded-For / X-Forwarded-Proto
38
+ ▼
39
+ 127.0.0.1:3080 (dsh web 本体)
40
+ ```
41
+
42
+ `dsh web` 只监听回环,且会校验 `Host` / `Origin` 是否「像本机访问」,直接暴露到局域网会被 403。
43
+ 以前靠 nginx 改写请求头,现在这段逻辑跑在插件里。
44
+
45
+ - 流式不缓冲(SSE、大文件下载不卡)
46
+ - WebSocket 用 `net.connect` 手写 101 透传
47
+ - 长连接超时对齐 nginx 的 3600s,请求体上限 200 MiB
48
+ - 端口被占每 5 秒重试,加载期绝不抛异常
49
+
50
+ ### 2. 局域网访问开关与端口(默认关闭 / 8080)
51
+
52
+ 默认只监听 `127.0.0.1:8080`,也就是**只有跑 DSH 的这台机器自己**能打开后台。
53
+ 要把后台共享给同一个 Wi-Fi / 局域网里的手机、平板、另一台电脑,必须在两个入口之一**显式确认**:
54
+
55
+ - 设置页:**设置 → 局域网访问**,点开关(紫色)→ 弹安全提示 → 点「确定」才生效;
56
+ 同一页还有「监听端口」输入框,改完点「保存」立刻切端口。
57
+ - 命令行(斜杠命令):在 DSH 输入框里发 `/lan` 看状态,`/lan yes` 开启(先给出同一份安全提示),`/lan no` 关闭。
58
+ - 命令行(终端):`reproxy-lan status` 看状态,`reproxy-lan enable` 需敲 `yes` 确认后才开,`reproxy-lan disable` 直接关。
59
+
60
+ 两个入口读写同一份状态文件 `<DSH_HOME>/plugin-reverse-proxy/lan-access.json`,
61
+ 所以永远同步;切换后立即重建监听,**重启 dsh 也不会丢**,不需要重新打开。
62
+
63
+ > ⚠️ 开启后,同一网络里的任何设备直接访问 `http://<这台机器的IP>:<端口>` 就能进入完整后台
64
+ > (会话、终端、设置),不需要 Token、不需要登录。只在信任当前局域网时开启。
65
+
66
+ #### 怎么用(三个入口,改的是同一份状态)
67
+
68
+ **① 设置页**
69
+
70
+ 设置 → 局域网访问 → 点开关 → 弹「对局域网开放访问?」→ 点「确定」才生效。
71
+ 左侧会同时显示「已开启 / 已关闭」,下面带状态与上次修改时间。
72
+
73
+ #### 改端口(默认 8080)
74
+
75
+ 同一页第二张卡片就是「监听端口」:输入框填数字 → 点 **保存** → 立刻重建监听,
76
+ **不用重启 dsh**,重启后也会保留。规则:1024–65535,不能占 3080(那是 DSH 自己的端口),
77
+ 不在这个区间或已被占用会直接报错、不改动现状(被占用会返回 409)。
78
+
79
+ 三个入口都能改端口:
80
+
81
+ ```
82
+ /lan port 看当前端口
83
+ /lan port 9000 改端口
84
+ reproxy-lan port 9000 (SSH 里)
85
+ ```
86
+
87
+ **② 对话输入框里的斜杠命令**
88
+
89
+ ```
90
+ /lan 看当前状态
91
+ /lan status 同上
92
+ /lan yes 开启(打 yes 即确认)
93
+ /lan no 关闭
94
+ ```
95
+
96
+ **③ 终端命令**(SSH 上机器)
97
+
98
+ ```bash
99
+ reproxy-lan status # 看状态
100
+ reproxy-lan enable # 先打安全提示,输入 yes 才真正开启
101
+ reproxy-lan disable # 直接关闭
102
+ reproxy-lan port 9000 # 改监听端口(1024–65535,不能占 3080)
103
+ reproxy-lan --help
104
+ ```
105
+
106
+ 终端示例(`status` → `enable` → 输入 `yes` 确认 → 立刻监听 `0.0.0.0:8080`):
107
+
108
+ ![reproxy-lan 终端示例](assets/lan-access-cli.jpg)
109
+
110
+ 切换后**立刻重建监听**(旧连接会断开,重新打开即可),**`systemctl restart dsh` 也不会丢**,
111
+ 因为状态存在 `<DSH_HOME>/plugin-reverse-proxy/lan-access.json`,一条 JSON 而已:
112
+
113
+ ```json
114
+ { "lanAccess": true, "port": 8080, "updatedAt": "2026-11-15T06:06:33.690Z", "updatedBy": "cli" }
115
+ ```
116
+
117
+ 想彻底关闭又不点开关?`reproxy-lan disable` 或 `/lan no` 都行;想手动改文件也可以,
118
+ 插件用 `fs.watch` 盯着它,改完一两秒内自动生效(`updatedBy` 可以写 `manual`)。
119
+
120
+ ### 3. 免 Token 登录(版本门控,命中才启用)
121
+
122
+ 替换官方 `@deepseek-ai/dsh-client-connection` 提供方,跳过 BrowserAuth:
123
+ 浏览器直接打开 Web 地址就能用。
124
+
125
+ - **web-only**:desktop 宿主一律休眠(多进程树判别),官方行为不受影响
126
+ - **精确版本白名单**:runtime 与 connection 包必须成对命中已知版本,否则自动休眠、官方 connection 原样保留
127
+ - **不改 DSH 本体**:只通过官方插件 patch 机制替换那一行,卸载/禁用即完全恢复
128
+ - 当前覆盖:`0.1.2-rc.1` `0.1.5-rc.1/rc.2` `0.1.7-rc.1/rc.2` `0.2.0-rc.1/rc.2` `0.2.1-rc.1~rc.5` `0.2.2-rc.1/rc.2/rc.3`
129
+
130
+ > 这部分参考并内联自 [`@iasiv5/dsh-skip-browser-auth`](https://github.com/iasiv5/dsh-skip-browser-auth)(MIT),
131
+ > 在 `vendor/skip/` 下,保留其 LICENSE 与 NOTICE。
132
+
133
+ ---
134
+
135
+ ## 适用范围
136
+
137
+ | 场景 | 能不能用 |
138
+ |---|---|
139
+ | **Web UI 版**(浏览器打开 `http://<局域网IP>:8080`,端口可改,需先开启局域网访问) | ✅ 就是给它用的 |
140
+ | **桌面版 / 客户端版** | ❌ 用不上,也不建议用 |
141
+
142
+ 桌面版本来就在本机跑,直连 `127.0.0.1:3080` 即可,不需要反代,也不需要跳过认证。
143
+
144
+ ---
145
+
146
+ ## 安装
147
+
148
+ ```bash
149
+ git clone https://github.com/llifco/dsh-plugin-reverse-proxy.git
150
+ cd dsh-plugin-reverse-proxy
151
+ dsh plugin --profile web add .
152
+ ```
153
+
154
+ 或用 Release 里的包:
155
+
156
+ ```bash
157
+ dsh plugin --profile web add ./dsh-plugin-reverse-proxy-0.3.3.tgz
158
+ ```
159
+
160
+ 装完重启一次宿主:
161
+
162
+ ```bash
163
+ systemctl restart dsh
164
+ ```
165
+
166
+ **默认只监听 `127.0.0.1:8080`**,所以装完先在本机打开 `http://127.0.0.1:8080` 确认能用。
167
+ 要让手机 / 平板 / 别的电脑进来,先开「局域网访问」开关(见上一节三种入口),
168
+ 再打开 `http://<这台机器的局域网IP>:8080`,无需 token。
169
+
170
+ 第一次开启建议用终端,确认提示看得清清楚楚:
171
+
172
+ ```bash
173
+ reproxy-lan enable # 读完提示,输入 yes
174
+ ```
175
+
176
+ ---
177
+
178
+ ## 配置
179
+
180
+ 反向代理(`cordis.patch.yml` 里 `dsh-plugin-reverse-proxy` 行):
181
+
182
+ | 配置项 | 默认值 | 对应原 nginx |
183
+ |---|---|---|
184
+ | `listenHost` | 由「局域网访问」开关决定(默认 `127.0.0.1`) | `listen 127.0.0.1:8080` |
185
+ | `listenPort` | 由设置页「监听端口」决定(默认 `8080`,存状态文件) | 不需要写配置 |
186
+ | `listenIpv6` | `false` | `listen [::]:8080` |
187
+ | `upstreamHost` / `upstreamPort` | `127.0.0.1` / `3080` | `proxy_pass` |
188
+ | `upstreamHostHeader` | `127.0.0.1:3080` | `proxy_set_header Host` |
189
+ | `upstreamOrigin` | `http://127.0.0.1:3080` | `proxy_set_header Origin` |
190
+ | `maxBodyBytes` | `209715200` | `client_max_body_size 200m` |
191
+ | `retryMs` | `5000` | —(端口冲突重试间隔) |
192
+
193
+ 免 Token 登录(`dsh-plugin-reverse-proxy-trusted-connection*` 行)的 `trustedHosts`
194
+ 由 DSH 的 Web 运行时配置自动注入,一般不用手改。
195
+
196
+ ---
197
+
198
+ ## 目录结构
199
+
200
+ ```
201
+ dsh-plugin-reverse-proxy/
202
+ ├── index.js # 入口:按 cordis 行 id 分发(反代 / 免登录)
203
+ ├── lan-access.js # 局域网访问开关:状态读写 + 监听重建
204
+ ├── cordis.patch.yml # 官方插件 patch:版本门控 + 插入两条能力行
205
+ ├── assets/logo.jpg # 仓库头像
206
+ ├── vendor/skip/ # 免 Token 登录实现(MIT,来自 dsh-skip-browser-auth)
207
+ │ ├── host.js gate.js compatibility.js
208
+ │ ├── trust-fence.js trusted-auth.js bridge.js
209
+ │ ├── connection-runtime.js
210
+ │ ├── adapters/ # carrier-neutral / -017 / -021
211
+ │ └── client.js # 浏览器端 bundle(已注入)
212
+ ├── dist/*.tgz # 打包产物(离线安装用)
213
+ ├── CHANGELOG.md
214
+ ├── README.md / README.en.md
215
+ └── LICENSE
216
+ ```
217
+
218
+ ---
219
+
220
+ ## 卸载 / 回退到 nginx
221
+
222
+ ```bash
223
+ dsh plugin --profile web remove dsh-plugin-reverse-proxy
224
+ systemctl restart dsh
225
+ ```
226
+
227
+ 退回 nginx 反代:
228
+
229
+ ```bash
230
+ ln -sf /etc/nginx/sites-available/dsh /etc/nginx/sites-enabled/dsh
231
+ nginx -t && systemctl reload nginx
232
+ ```
233
+
234
+ ---
235
+
236
+ ## 常见问题
237
+
238
+ **Q:只能本机打开,手机/局域网里的设备打不开?**
239
+ 这是 0.3.2 起的新默认:只监听 `127.0.0.1`。用 `/lan yes` 或 `reproxy-lan enable` 开启,
240
+ 或者去 设置 → 局域网访问 点开关。开完 `ss -ltnp | grep 8080` 应该看到 `0.0.0.0:8080`。
241
+
242
+ **Q:能不能用别的端口?比如 3000、9000?**
243
+
244
+ 能。设置 → 局域网访问 → 第二张卡「监听端口」→ 填数字 → **保存**,立刻切换(不用重启)。
245
+ 也可以在输入框发 `/lan port 9000`,或 SSH 里 `reproxy-lan port 9000`。允许 1024–65535。
246
+
247
+ **Q:能不能用 80 / 443 这种端口?**
248
+
249
+ 当前版本限制在 1024 以上,故意不给选 80——本机如果还留着 nginx,80 会被它占着;
250
+ 而且 80 是最容易被局域网里乱扫描的设备撞上的端口,安全上不划算。想改这段门槛,
251
+ 得改 `lan-access.js` 的 `validatePort()` 并确保进程有绑定特权端口的权限。
252
+
253
+ **Q:装完 8080 还是打不开?**
254
+ `ss -ltnp | grep 8080` 看占用者。还是 nginx 的话,旧的 `sites-enabled/dsh` 软链没删,两个会抢端口。
255
+
256
+ **Q:打开又要 token 了?**
257
+ 说明免登录那半休眠了——多半是 DSH 升级后版本不在白名单里。看日志有没有
258
+ `BrowserAuth has been skipped`;没有就是休眠,官方行为,功能上等价。
259
+
260
+ **Q:能穿透公网吗?**
261
+ 不能,也不建议。它只把「局域网可访问」做对;公网请自己加隧道并做鉴权。
262
+
263
+ **Q:桌面版能用吗?**
264
+ 用不上——桌面版本机直连 `127.0.0.1:3080` 即可。
265
+
266
+ ---
267
+
268
+ ## 反馈
269
+
270
+ - 问题反馈 / 功能建议 / 装不上的报错:**QQ 3538638569**(3538638569@qq.com)
271
+ - 反馈时带上 `dsh --version`、`dsh plugin --profile web list` 和你看到的日志,能快很多。
272
+
273
+ ## 许可
274
+
275
+ MIT(`vendor/skip/` 内代码来自 @iasiv5/dsh-skip-browser-auth,同样 MIT)
Binary file
Binary file
@@ -0,0 +1,75 @@
1
+ # dsh-plugin-reverse-proxy — 反代 + 免 Token 登录(合并版 0.2.0)
2
+ #
3
+ # 两条能力,同一个包:
4
+ # 1) 反向代理:0.0.0.0:8080 → 127.0.0.1:3080(改写 Host/Origin/Sec-Fetch-Site)
5
+ # 2) 免 Token 登录:替换官方 Connection 提供方跳过 BrowserAuth(web-only,版本门控)
6
+ #
7
+ # 第 2 条只在版本门控命中时生效;不命中则官方 connection 原样保留(自动休眠)。
8
+ # 免登录部分源码参考并内联自 @iasiv5/dsh-skip-browser-auth(MIT,见 vendor/skip/LICENSE)。
9
+
10
+ - id: connection
11
+ name: '@deepseek-ai/dsh-client-connection'
12
+ disabled: !!js >-
13
+ (() => { try { const profile = ((() => { try { const internal = ctx.loader && ctx.loader.internal; if (!internal || typeof internal.resolveSync !== 'function') return null; const desktopSpecifier = "@deepseek-ai/dsh-desktop-host" + '/package.json'; let hostProfile = 'web'; let hostProcess = null; try { if (typeof process === 'object' && process !== null) hostProcess = process; } catch (sigError0) { } let slot = ''; let desktopBySlot = false; try { const decodedBase = decodeURIComponent(typeof ctx.baseUrl === 'string' ? ctx.baseUrl : ''); const trimmedBase = decodedBase.endsWith('/') ? decodedBase.slice(0, -1) : decodedBase; slot = trimmedBase.slice(trimmedBase.lastIndexOf('/') + 1).toLowerCase(); desktopBySlot = slot === "desktop"; } catch (sigError1) { } let desktopByArgv = false; try { if (hostProcess !== null && typeof hostProcess === 'object' && Array.isArray(hostProcess.argv)) desktopByArgv = hostProcess.argv.some((arg) => typeof arg === 'string' &&
14
+ arg.indexOf("dsh-desktop-host") !== -1); } catch (sigError2) { } let webByBinary = false; try { if (hostProcess !== null && typeof hostProcess === 'object' && typeof hostProcess.execPath === 'string') { const execBase = hostProcess.execPath.slice(Math.max(hostProcess.execPath.lastIndexOf('/'), hostProcess.execPath.lastIndexOf('\\')) + 1).toLowerCase(); webByBinary = execBase === 'node' || execBase === 'node.exe' || execBase === 'nodejs' || execBase === 'nodejs.exe'; } } catch (sigError3) { } let desktopByPackage = false; try { const desktopResolved = internal.version === 'v2' ? internal.resolveSync(ctx.baseUrl, { specifier: desktopSpecifier, attributes: {} }) : internal.resolveSync(desktopSpecifier, ctx.baseUrl, {}); const desktopUrl = desktopResolved === null || typeof desktopResolved !== 'object' ? undefined : desktopResolved.url; desktopByPackage = typeof desktopUrl === 'string'; } catch (sigError4) { } hostProfile = desktopByArgv || desktopBySlot || desktopByPackage ||
15
+ !webByBinary ? 'desktop' : 'web'; const versionOfUrl = (url, patternSource) => { if (typeof url !== 'string') return null; const decoded = decodeURIComponent(url); const segmented = decoded.match(new RegExp(patternSource)); if (segmented !== null) return segmented[1]; if (decoded.slice(0, 5) === 'file:') { const processRef = globalThis.process; if (processRef === null || typeof processRef !== 'object' || typeof processRef.getBuiltinModule !== 'function') return null; const fsModule = processRef.getBuiltinModule('node:fs'); const urlModule = processRef.getBuiltinModule('node:url'); if (!fsModule || typeof fsModule.readFileSync !== 'function' || !urlModule || typeof urlModule.fileURLToPath !== 'function') return null; const manifest = JSON.parse(fsModule.readFileSync(urlModule.fileURLToPath(url), 'utf8')); return manifest !== null && typeof manifest === 'object' && typeof manifest.version === 'string' ? manifest.version : null; } return null; }; const anchors =
16
+ [["@deepseek-ai/dsh","[+]dsh@([^/_]+)[_/]"],["@deepseek-ai/dsh-client-connection","[+]dsh-client-connection@([^/_]+)[_/]"]]; const versions = []; for (const [anchorPackage, patternSource] of anchors) { const specifier = anchorPackage + '/package.json'; let url; try { url = internal.version === 'v2' ? internal.resolveSync(ctx.baseUrl, { specifier, attributes: {} }).url : internal.resolveSync(specifier, ctx.baseUrl, {}).url; } catch (gateError) { return null; } let anchorVersion; try { anchorVersion = versionOfUrl(url, patternSource); } catch (gateError) { return null; } if (anchorVersion === null) return null; versions.push(anchorVersion); } const profiles =
17
+ [{"id":"legacy-web-v1","pairs":[{"runtime":"0.1.2-rc.1","connection":"0.1.2-rc.1"}],"hostProfiles":["web"]},{"id":"carrier-neutral-v2","pairs":[{"runtime":"0.1.5-rc.1","connection":"0.1.5-rc.1"},{"runtime":"0.1.5-rc.2","connection":"0.1.5-rc.2"}],"hostProfiles":["web"]},{"id":"carrier-neutral-v3","pairs":[{"runtime":"0.1.7-rc.1","connection":"0.1.7-rc.1"},{"runtime":"0.1.7-rc.2","connection":"0.1.7-rc.2"},{"runtime":"0.2.0-rc.1","connection":"0.2.0-rc.1"},{"runtime":"0.2.0-rc.2","connection":"0.2.0-rc.2"}],"hostProfiles":["web"]},{"id":"carrier-neutral-v4","pairs":[{"runtime":"0.2.1-rc.1","connection":"0.2.1-rc.1"},{"runtime":"0.2.1-rc.2","connection":"0.2.1-rc.2"},{"runtime":"0.2.1-rc.3","connection":"0.2.1-rc.3"},{"runtime":"0.2.1-rc.4","connection":"0.2.1-rc.4"},{"runtime":"0.2.1-rc.5","connection":"0.2.1-rc.5"},{"runtime":"0.2.2-rc.1","connection":"0.2.2-rc.1"},{"runtime":"0.2.2-rc.2","connection":"0.2.2-rc.2"},{"runtime":"0.2.2-rc.3","connection":"0.2.2-rc.3"}],"hostProfiles":["web"]}]; for (const profile of profiles) { if (profile.hostProfiles.includes(hostProfile) &&
18
+ profile.pairs.some((pair) => pair.runtime === versions[0] && pair.connection === versions[1])) return profile.id; } return null; } catch (gateError) { return null; } })()); return profile !== null && ["legacy-web-v1","carrier-neutral-v2","carrier-neutral-v3","carrier-neutral-v4"].includes(profile); } catch (gateError) { return false; } })()
19
+ - insert:
20
+ - id: dsh-plugin-reverse-proxy-trusted-connection
21
+ name: 'dsh-plugin-reverse-proxy'
22
+ inject:
23
+ - webRuntime
24
+ config:
25
+ trustedHosts: !!js ctx.webRuntime.trustedHosts
26
+ compatibilityProfile: !!js >-
27
+ (() => { try { const internal = ctx.loader && ctx.loader.internal; if (!internal || typeof internal.resolveSync !== 'function') return null; const desktopSpecifier = "@deepseek-ai/dsh-desktop-host" + '/package.json'; let hostProfile = 'web'; let hostProcess = null; try { if (typeof process === 'object' && process !== null) hostProcess = process; } catch (sigError0) { } let slot = ''; let desktopBySlot = false; try { const decodedBase = decodeURIComponent(typeof ctx.baseUrl === 'string' ? ctx.baseUrl : ''); const trimmedBase = decodedBase.endsWith('/') ? decodedBase.slice(0, -1) : decodedBase; slot = trimmedBase.slice(trimmedBase.lastIndexOf('/') + 1).toLowerCase(); desktopBySlot = slot === "desktop"; } catch (sigError1) { } let desktopByArgv = false; try { if (hostProcess !== null && typeof hostProcess === 'object' && Array.isArray(hostProcess.argv)) desktopByArgv = hostProcess.argv.some((arg) => typeof arg === 'string' && arg.indexOf("dsh-desktop-host") !== -1); } catch
28
+ (sigError2) { } let webByBinary = false; try { if (hostProcess !== null && typeof hostProcess === 'object' && typeof hostProcess.execPath === 'string') { const execBase = hostProcess.execPath.slice(Math.max(hostProcess.execPath.lastIndexOf('/'), hostProcess.execPath.lastIndexOf('\\')) + 1).toLowerCase(); webByBinary = execBase === 'node' || execBase === 'node.exe' || execBase === 'nodejs' || execBase === 'nodejs.exe'; } } catch (sigError3) { } let desktopByPackage = false; try { const desktopResolved = internal.version === 'v2' ? internal.resolveSync(ctx.baseUrl, { specifier: desktopSpecifier, attributes: {} }) : internal.resolveSync(desktopSpecifier, ctx.baseUrl, {}); const desktopUrl = desktopResolved === null || typeof desktopResolved !== 'object' ? undefined : desktopResolved.url; desktopByPackage = typeof desktopUrl === 'string'; } catch (sigError4) { } hostProfile = desktopByArgv || desktopBySlot || desktopByPackage || !webByBinary ? 'desktop' : 'web'; const
29
+ versionOfUrl = (url, patternSource) => { if (typeof url !== 'string') return null; const decoded = decodeURIComponent(url); const segmented = decoded.match(new RegExp(patternSource)); if (segmented !== null) return segmented[1]; if (decoded.slice(0, 5) === 'file:') { const processRef = globalThis.process; if (processRef === null || typeof processRef !== 'object' || typeof processRef.getBuiltinModule !== 'function') return null; const fsModule = processRef.getBuiltinModule('node:fs'); const urlModule = processRef.getBuiltinModule('node:url'); if (!fsModule || typeof fsModule.readFileSync !== 'function' || !urlModule || typeof urlModule.fileURLToPath !== 'function') return null; const manifest = JSON.parse(fsModule.readFileSync(urlModule.fileURLToPath(url), 'utf8')); return manifest !== null && typeof manifest === 'object' && typeof manifest.version === 'string' ? manifest.version : null; } return null; }; const anchors =
30
+ [["@deepseek-ai/dsh","[+]dsh@([^/_]+)[_/]"],["@deepseek-ai/dsh-client-connection","[+]dsh-client-connection@([^/_]+)[_/]"]]; const versions = []; for (const [anchorPackage, patternSource] of anchors) { const specifier = anchorPackage + '/package.json'; let url; try { url = internal.version === 'v2' ? internal.resolveSync(ctx.baseUrl, { specifier, attributes: {} }).url : internal.resolveSync(specifier, ctx.baseUrl, {}).url; } catch (gateError) { return null; } let anchorVersion; try { anchorVersion = versionOfUrl(url, patternSource); } catch (gateError) { return null; } if (anchorVersion === null) return null; versions.push(anchorVersion); } const profiles =
31
+ [{"id":"legacy-web-v1","pairs":[{"runtime":"0.1.2-rc.1","connection":"0.1.2-rc.1"}],"hostProfiles":["web"]},{"id":"carrier-neutral-v2","pairs":[{"runtime":"0.1.5-rc.1","connection":"0.1.5-rc.1"},{"runtime":"0.1.5-rc.2","connection":"0.1.5-rc.2"}],"hostProfiles":["web"]},{"id":"carrier-neutral-v3","pairs":[{"runtime":"0.1.7-rc.1","connection":"0.1.7-rc.1"},{"runtime":"0.1.7-rc.2","connection":"0.1.7-rc.2"},{"runtime":"0.2.0-rc.1","connection":"0.2.0-rc.1"},{"runtime":"0.2.0-rc.2","connection":"0.2.0-rc.2"}],"hostProfiles":["web"]},{"id":"carrier-neutral-v4","pairs":[{"runtime":"0.2.1-rc.1","connection":"0.2.1-rc.1"},{"runtime":"0.2.1-rc.2","connection":"0.2.1-rc.2"},{"runtime":"0.2.1-rc.3","connection":"0.2.1-rc.3"},{"runtime":"0.2.1-rc.4","connection":"0.2.1-rc.4"},{"runtime":"0.2.1-rc.5","connection":"0.2.1-rc.5"},{"runtime":"0.2.2-rc.1","connection":"0.2.2-rc.1"},{"runtime":"0.2.2-rc.2","connection":"0.2.2-rc.2"},{"runtime":"0.2.2-rc.3","connection":"0.2.2-rc.3"}],"hostProfiles":["web"]}]; for (const profile of profiles) { if (profile.hostProfiles.includes(hostProfile) &&
32
+ profile.pairs.some((pair) => pair.runtime === versions[0] && pair.connection === versions[1])) return profile.id; } return null; } catch (gateError) { return null; } })()
33
+ disabled: !!js >-
34
+ !((() => { try { const self = ctx[Symbol.for('cordis.entry')]; if (!self || !self.parent || !self.parent.tree) return false; const official = self.parent.tree.resolve('connection'); if (!official || official.parent !== self.parent) return false; if (official.options.id !== 'connection' || official.options.name !== '@deepseek-ai/dsh-client-connection') return false; const profile = ((() => { try { const internal = ctx.loader && ctx.loader.internal; if (!internal || typeof internal.resolveSync !== 'function') return null; const desktopSpecifier = "@deepseek-ai/dsh-desktop-host" + '/package.json'; let hostProfile = 'web'; let hostProcess = null; try { if (typeof process === 'object' && process !== null) hostProcess = process; } catch (sigError0) { } let slot = ''; let desktopBySlot = false; try { const decodedBase = decodeURIComponent(typeof ctx.baseUrl === 'string' ? ctx.baseUrl : ''); const trimmedBase = decodedBase.endsWith('/') ? decodedBase.slice(0, -1) : decodedBase; slot =
35
+ trimmedBase.slice(trimmedBase.lastIndexOf('/') + 1).toLowerCase(); desktopBySlot = slot === "desktop"; } catch (sigError1) { } let desktopByArgv = false; try { if (hostProcess !== null && typeof hostProcess === 'object' && Array.isArray(hostProcess.argv)) desktopByArgv = hostProcess.argv.some((arg) => typeof arg === 'string' && arg.indexOf("dsh-desktop-host") !== -1); } catch (sigError2) { } let webByBinary = false; try { if (hostProcess !== null && typeof hostProcess === 'object' && typeof hostProcess.execPath === 'string') { const execBase = hostProcess.execPath.slice(Math.max(hostProcess.execPath.lastIndexOf('/'), hostProcess.execPath.lastIndexOf('\\')) + 1).toLowerCase(); webByBinary = execBase === 'node' || execBase === 'node.exe' || execBase === 'nodejs' || execBase === 'nodejs.exe'; } } catch (sigError3) { } let desktopByPackage = false; try { const desktopResolved = internal.version === 'v2' ? internal.resolveSync(ctx.baseUrl, { specifier: desktopSpecifier, attributes:
36
+ {} }) : internal.resolveSync(desktopSpecifier, ctx.baseUrl, {}); const desktopUrl = desktopResolved === null || typeof desktopResolved !== 'object' ? undefined : desktopResolved.url; desktopByPackage = typeof desktopUrl === 'string'; } catch (sigError4) { } hostProfile = desktopByArgv || desktopBySlot || desktopByPackage || !webByBinary ? 'desktop' : 'web'; const versionOfUrl = (url, patternSource) => { if (typeof url !== 'string') return null; const decoded = decodeURIComponent(url); const segmented = decoded.match(new RegExp(patternSource)); if (segmented !== null) return segmented[1]; if (decoded.slice(0, 5) === 'file:') { const processRef = globalThis.process; if (processRef === null || typeof processRef !== 'object' || typeof processRef.getBuiltinModule !== 'function') return null; const fsModule = processRef.getBuiltinModule('node:fs'); const urlModule = processRef.getBuiltinModule('node:url'); if (!fsModule || typeof fsModule.readFileSync !== 'function' || !urlModule ||
37
+ typeof urlModule.fileURLToPath !== 'function') return null; const manifest = JSON.parse(fsModule.readFileSync(urlModule.fileURLToPath(url), 'utf8')); return manifest !== null && typeof manifest === 'object' && typeof manifest.version === 'string' ? manifest.version : null; } return null; }; const anchors = [["@deepseek-ai/dsh","[+]dsh@([^/_]+)[_/]"],["@deepseek-ai/dsh-client-connection","[+]dsh-client-connection@([^/_]+)[_/]"]]; const versions = []; for (const [anchorPackage, patternSource] of anchors) { const specifier = anchorPackage + '/package.json'; let url; try { url = internal.version === 'v2' ? internal.resolveSync(ctx.baseUrl, { specifier, attributes: {} }).url : internal.resolveSync(specifier, ctx.baseUrl, {}).url; } catch (gateError) { return null; } let anchorVersion; try { anchorVersion = versionOfUrl(url, patternSource); } catch (gateError) { return null; } if (anchorVersion === null) return null; versions.push(anchorVersion); } const profiles =
38
+ [{"id":"legacy-web-v1","pairs":[{"runtime":"0.1.2-rc.1","connection":"0.1.2-rc.1"}],"hostProfiles":["web"]},{"id":"carrier-neutral-v2","pairs":[{"runtime":"0.1.5-rc.1","connection":"0.1.5-rc.1"},{"runtime":"0.1.5-rc.2","connection":"0.1.5-rc.2"}],"hostProfiles":["web"]},{"id":"carrier-neutral-v3","pairs":[{"runtime":"0.1.7-rc.1","connection":"0.1.7-rc.1"},{"runtime":"0.1.7-rc.2","connection":"0.1.7-rc.2"},{"runtime":"0.2.0-rc.1","connection":"0.2.0-rc.1"},{"runtime":"0.2.0-rc.2","connection":"0.2.0-rc.2"}],"hostProfiles":["web"]},{"id":"carrier-neutral-v4","pairs":[{"runtime":"0.2.1-rc.1","connection":"0.2.1-rc.1"},{"runtime":"0.2.1-rc.2","connection":"0.2.1-rc.2"},{"runtime":"0.2.1-rc.3","connection":"0.2.1-rc.3"},{"runtime":"0.2.1-rc.4","connection":"0.2.1-rc.4"},{"runtime":"0.2.1-rc.5","connection":"0.2.1-rc.5"},{"runtime":"0.2.2-rc.1","connection":"0.2.2-rc.1"},{"runtime":"0.2.2-rc.2","connection":"0.2.2-rc.2"},{"runtime":"0.2.2-rc.3","connection":"0.2.2-rc.3"}],"hostProfiles":["web"]}]; for (const profile of profiles) { if (profile.hostProfiles.includes(hostProfile) &&
39
+ profile.pairs.some((pair) => pair.runtime === versions[0] && pair.connection === versions[1])) return profile.id; } return null; } catch (gateError) { return null; } })()); if (profile === null || !["legacy-web-v1","carrier-neutral-v2","carrier-neutral-v3"].includes(profile)) return false; return official.disabled === true; } catch (gateError) { return false; } })())
40
+ - id: dsh-plugin-reverse-proxy-trusted-connection-021
41
+ name: 'dsh-plugin-reverse-proxy'
42
+ inject:
43
+ - webStartup
44
+ config:
45
+ trustedHosts: !!js ctx.webStartup.trustedHosts
46
+ compatibilityProfile: !!js >-
47
+ (() => { try { const internal = ctx.loader && ctx.loader.internal; if (!internal || typeof internal.resolveSync !== 'function') return null; const desktopSpecifier = "@deepseek-ai/dsh-desktop-host" + '/package.json'; let hostProfile = 'web'; let hostProcess = null; try { if (typeof process === 'object' && process !== null) hostProcess = process; } catch (sigError0) { } let slot = ''; let desktopBySlot = false; try { const decodedBase = decodeURIComponent(typeof ctx.baseUrl === 'string' ? ctx.baseUrl : ''); const trimmedBase = decodedBase.endsWith('/') ? decodedBase.slice(0, -1) : decodedBase; slot = trimmedBase.slice(trimmedBase.lastIndexOf('/') + 1).toLowerCase(); desktopBySlot = slot === "desktop"; } catch (sigError1) { } let desktopByArgv = false; try { if (hostProcess !== null && typeof hostProcess === 'object' && Array.isArray(hostProcess.argv)) desktopByArgv = hostProcess.argv.some((arg) => typeof arg === 'string' && arg.indexOf("dsh-desktop-host") !== -1); } catch
48
+ (sigError2) { } let webByBinary = false; try { if (hostProcess !== null && typeof hostProcess === 'object' && typeof hostProcess.execPath === 'string') { const execBase = hostProcess.execPath.slice(Math.max(hostProcess.execPath.lastIndexOf('/'), hostProcess.execPath.lastIndexOf('\\')) + 1).toLowerCase(); webByBinary = execBase === 'node' || execBase === 'node.exe' || execBase === 'nodejs' || execBase === 'nodejs.exe'; } } catch (sigError3) { } let desktopByPackage = false; try { const desktopResolved = internal.version === 'v2' ? internal.resolveSync(ctx.baseUrl, { specifier: desktopSpecifier, attributes: {} }) : internal.resolveSync(desktopSpecifier, ctx.baseUrl, {}); const desktopUrl = desktopResolved === null || typeof desktopResolved !== 'object' ? undefined : desktopResolved.url; desktopByPackage = typeof desktopUrl === 'string'; } catch (sigError4) { } hostProfile = desktopByArgv || desktopBySlot || desktopByPackage || !webByBinary ? 'desktop' : 'web'; const
49
+ versionOfUrl = (url, patternSource) => { if (typeof url !== 'string') return null; const decoded = decodeURIComponent(url); const segmented = decoded.match(new RegExp(patternSource)); if (segmented !== null) return segmented[1]; if (decoded.slice(0, 5) === 'file:') { const processRef = globalThis.process; if (processRef === null || typeof processRef !== 'object' || typeof processRef.getBuiltinModule !== 'function') return null; const fsModule = processRef.getBuiltinModule('node:fs'); const urlModule = processRef.getBuiltinModule('node:url'); if (!fsModule || typeof fsModule.readFileSync !== 'function' || !urlModule || typeof urlModule.fileURLToPath !== 'function') return null; const manifest = JSON.parse(fsModule.readFileSync(urlModule.fileURLToPath(url), 'utf8')); return manifest !== null && typeof manifest === 'object' && typeof manifest.version === 'string' ? manifest.version : null; } return null; }; const anchors =
50
+ [["@deepseek-ai/dsh","[+]dsh@([^/_]+)[_/]"],["@deepseek-ai/dsh-client-connection","[+]dsh-client-connection@([^/_]+)[_/]"]]; const versions = []; for (const [anchorPackage, patternSource] of anchors) { const specifier = anchorPackage + '/package.json'; let url; try { url = internal.version === 'v2' ? internal.resolveSync(ctx.baseUrl, { specifier, attributes: {} }).url : internal.resolveSync(specifier, ctx.baseUrl, {}).url; } catch (gateError) { return null; } let anchorVersion; try { anchorVersion = versionOfUrl(url, patternSource); } catch (gateError) { return null; } if (anchorVersion === null) return null; versions.push(anchorVersion); } const profiles =
51
+ [{"id":"legacy-web-v1","pairs":[{"runtime":"0.1.2-rc.1","connection":"0.1.2-rc.1"}],"hostProfiles":["web"]},{"id":"carrier-neutral-v2","pairs":[{"runtime":"0.1.5-rc.1","connection":"0.1.5-rc.1"},{"runtime":"0.1.5-rc.2","connection":"0.1.5-rc.2"}],"hostProfiles":["web"]},{"id":"carrier-neutral-v3","pairs":[{"runtime":"0.1.7-rc.1","connection":"0.1.7-rc.1"},{"runtime":"0.1.7-rc.2","connection":"0.1.7-rc.2"},{"runtime":"0.2.0-rc.1","connection":"0.2.0-rc.1"},{"runtime":"0.2.0-rc.2","connection":"0.2.0-rc.2"}],"hostProfiles":["web"]},{"id":"carrier-neutral-v4","pairs":[{"runtime":"0.2.1-rc.1","connection":"0.2.1-rc.1"},{"runtime":"0.2.1-rc.2","connection":"0.2.1-rc.2"},{"runtime":"0.2.1-rc.3","connection":"0.2.1-rc.3"},{"runtime":"0.2.1-rc.4","connection":"0.2.1-rc.4"},{"runtime":"0.2.1-rc.5","connection":"0.2.1-rc.5"},{"runtime":"0.2.2-rc.1","connection":"0.2.2-rc.1"},{"runtime":"0.2.2-rc.2","connection":"0.2.2-rc.2"},{"runtime":"0.2.2-rc.3","connection":"0.2.2-rc.3"}],"hostProfiles":["web"]}]; for (const profile of profiles) { if (profile.hostProfiles.includes(hostProfile) &&
52
+ profile.pairs.some((pair) => pair.runtime === versions[0] && pair.connection === versions[1])) return profile.id; } return null; } catch (gateError) { return null; } })()
53
+ disabled: !!js >-
54
+ !((() => { try { const self = ctx[Symbol.for('cordis.entry')]; if (!self || !self.parent || !self.parent.tree) return false; const official = self.parent.tree.resolve('connection'); if (!official || official.parent !== self.parent) return false; if (official.options.id !== 'connection' || official.options.name !== '@deepseek-ai/dsh-client-connection') return false; const profile = ((() => { try { const internal = ctx.loader && ctx.loader.internal; if (!internal || typeof internal.resolveSync !== 'function') return null; const desktopSpecifier = "@deepseek-ai/dsh-desktop-host" + '/package.json'; let hostProfile = 'web'; let hostProcess = null; try { if (typeof process === 'object' && process !== null) hostProcess = process; } catch (sigError0) { } let slot = ''; let desktopBySlot = false; try { const decodedBase = decodeURIComponent(typeof ctx.baseUrl === 'string' ? ctx.baseUrl : ''); const trimmedBase = decodedBase.endsWith('/') ? decodedBase.slice(0, -1) : decodedBase; slot =
55
+ trimmedBase.slice(trimmedBase.lastIndexOf('/') + 1).toLowerCase(); desktopBySlot = slot === "desktop"; } catch (sigError1) { } let desktopByArgv = false; try { if (hostProcess !== null && typeof hostProcess === 'object' && Array.isArray(hostProcess.argv)) desktopByArgv = hostProcess.argv.some((arg) => typeof arg === 'string' && arg.indexOf("dsh-desktop-host") !== -1); } catch (sigError2) { } let webByBinary = false; try { if (hostProcess !== null && typeof hostProcess === 'object' && typeof hostProcess.execPath === 'string') { const execBase = hostProcess.execPath.slice(Math.max(hostProcess.execPath.lastIndexOf('/'), hostProcess.execPath.lastIndexOf('\\')) + 1).toLowerCase(); webByBinary = execBase === 'node' || execBase === 'node.exe' || execBase === 'nodejs' || execBase === 'nodejs.exe'; } } catch (sigError3) { } let desktopByPackage = false; try { const desktopResolved = internal.version === 'v2' ? internal.resolveSync(ctx.baseUrl, { specifier: desktopSpecifier, attributes:
56
+ {} }) : internal.resolveSync(desktopSpecifier, ctx.baseUrl, {}); const desktopUrl = desktopResolved === null || typeof desktopResolved !== 'object' ? undefined : desktopResolved.url; desktopByPackage = typeof desktopUrl === 'string'; } catch (sigError4) { } hostProfile = desktopByArgv || desktopBySlot || desktopByPackage || !webByBinary ? 'desktop' : 'web'; const versionOfUrl = (url, patternSource) => { if (typeof url !== 'string') return null; const decoded = decodeURIComponent(url); const segmented = decoded.match(new RegExp(patternSource)); if (segmented !== null) return segmented[1]; if (decoded.slice(0, 5) === 'file:') { const processRef = globalThis.process; if (processRef === null || typeof processRef !== 'object' || typeof processRef.getBuiltinModule !== 'function') return null; const fsModule = processRef.getBuiltinModule('node:fs'); const urlModule = processRef.getBuiltinModule('node:url'); if (!fsModule || typeof fsModule.readFileSync !== 'function' || !urlModule ||
57
+ typeof urlModule.fileURLToPath !== 'function') return null; const manifest = JSON.parse(fsModule.readFileSync(urlModule.fileURLToPath(url), 'utf8')); return manifest !== null && typeof manifest === 'object' && typeof manifest.version === 'string' ? manifest.version : null; } return null; }; const anchors = [["@deepseek-ai/dsh","[+]dsh@([^/_]+)[_/]"],["@deepseek-ai/dsh-client-connection","[+]dsh-client-connection@([^/_]+)[_/]"]]; const versions = []; for (const [anchorPackage, patternSource] of anchors) { const specifier = anchorPackage + '/package.json'; let url; try { url = internal.version === 'v2' ? internal.resolveSync(ctx.baseUrl, { specifier, attributes: {} }).url : internal.resolveSync(specifier, ctx.baseUrl, {}).url; } catch (gateError) { return null; } let anchorVersion; try { anchorVersion = versionOfUrl(url, patternSource); } catch (gateError) { return null; } if (anchorVersion === null) return null; versions.push(anchorVersion); } const profiles =
58
+ [{"id":"legacy-web-v1","pairs":[{"runtime":"0.1.2-rc.1","connection":"0.1.2-rc.1"}],"hostProfiles":["web"]},{"id":"carrier-neutral-v2","pairs":[{"runtime":"0.1.5-rc.1","connection":"0.1.5-rc.1"},{"runtime":"0.1.5-rc.2","connection":"0.1.5-rc.2"}],"hostProfiles":["web"]},{"id":"carrier-neutral-v3","pairs":[{"runtime":"0.1.7-rc.1","connection":"0.1.7-rc.1"},{"runtime":"0.1.7-rc.2","connection":"0.1.7-rc.2"},{"runtime":"0.2.0-rc.1","connection":"0.2.0-rc.1"},{"runtime":"0.2.0-rc.2","connection":"0.2.0-rc.2"}],"hostProfiles":["web"]},{"id":"carrier-neutral-v4","pairs":[{"runtime":"0.2.1-rc.1","connection":"0.2.1-rc.1"},{"runtime":"0.2.1-rc.2","connection":"0.2.1-rc.2"},{"runtime":"0.2.1-rc.3","connection":"0.2.1-rc.3"},{"runtime":"0.2.1-rc.4","connection":"0.2.1-rc.4"},{"runtime":"0.2.1-rc.5","connection":"0.2.1-rc.5"},{"runtime":"0.2.2-rc.1","connection":"0.2.2-rc.1"},{"runtime":"0.2.2-rc.2","connection":"0.2.2-rc.2"},{"runtime":"0.2.2-rc.3","connection":"0.2.2-rc.3"}],"hostProfiles":["web"]}]; for (const profile of profiles) { if (profile.hostProfiles.includes(hostProfile) &&
59
+ profile.pairs.some((pair) => pair.runtime === versions[0] && pair.connection === versions[1])) return profile.id; } return null; } catch (gateError) { return null; } })()); if (profile === null || !["carrier-neutral-v4"].includes(profile)) return false; return official.disabled === true; } catch (gateError) { return false; } })())
60
+
61
+ # 反向代理本体:与免登录替换互不依赖,始终生效
62
+ - insert:
63
+ - id: dsh-plugin-reverse-proxy
64
+ name: 'dsh-plugin-reverse-proxy'
65
+ config:
66
+ # 监听地址由「局域网访问」开关决定(默认 127.0.0.1);
67
+ # 端口由设置页/斜杠命令/命令行写入状态文件(默认 8080),这一行只是首装默认值
68
+ listenPort: 8080
69
+ listenIpv6: false
70
+ upstreamHost: '127.0.0.1'
71
+ upstreamPort: 3080
72
+ upstreamHostHeader: '127.0.0.1:3080'
73
+ upstreamOrigin: 'http://127.0.0.1:3080'
74
+ maxBodyBytes: 209715200
75
+ retryMs: 5000