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/CHANGELOG.md ADDED
@@ -0,0 +1,161 @@
1
+ # 更新日志
2
+
3
+ 本文件记录每个版本改了什么。格式:版本号(日期)先概述,再分条列具体改动。
4
+
5
+ ---
6
+
7
+ ## 0.3.5(2026-11-17)
8
+
9
+ **一句话:设置页的开关换成紫色,并新增「监听端口」输入框(保存即生效、重启保留)。**
10
+
11
+ ### 更新
12
+
13
+ - 设置页「局域网访问」开关改用紫色(`#8b5cf6`)+ 白色圆钮,深色主题下更显眼。
14
+ - 新增「监听端口」输入框:默认 8080,允许 1024–65535,改完点「保存」立即重建监听(不用重启 dsh),重启后保留。
15
+ - 端口也进状态文件 `<DSH_HOME>/plugin-reverse-proxy/lan-access.json` 的 `port` 字段;设置页、斜杠命令、命令行三个入口读写同一份。
16
+ - `POST /reproxy-lan/port` 新接口:先探测端口是否被占(被占返回 409),再写入并重建监听。
17
+ - 斜杠命令扩展:`/lan port` 看当前端口、`/lan port 9000` 直接改。
18
+ - `GET /reproxy-lan/status` 多返回 `defaultPort`,方便前端显示默认值。
19
+
20
+ ### 修复
21
+
22
+ - 端口从未真正生效过(`normalize()` 一直读配置里的 8080),现在以状态文件为准。
23
+
24
+ ---
25
+
26
+ ## 0.3.4(2026-11-15)
27
+
28
+ **一句话:只打包文档,把 0.3.x 的用法和截图一起塞进发行包(代码与 0.3.3 相同)。**
29
+
30
+ ### 文档
31
+
32
+ - README / README.en:新增「局域网访问」完整用法(设置页开关、`/lan` 斜杠命令、
33
+ 终端 `reproxy-lan status|enable|disable`)、状态文件说明、终端示例截图 `assets/lan-access-cli.jpg`。
34
+ - 明确默认只监听 `127.0.0.1:8080`;安装段、适用范围与 FAQ 同步补「要开开关才对外」。
35
+ - 免 Token 登录覆盖版本补 `0.2.2-rc.2/rc.3`;目录结构补 `lan-access.js`。
36
+ - `package.json` 的 `files` 增加 `assets`、`README.en.md`,保证包内 README 的图片能正常显示。
37
+
38
+ ---
39
+
40
+ ## 0.3.3(2026-11-15)
41
+
42
+ **一句话:设置页里的「局域网访问」开关真的会出现了(0.3.2 的入口实际没渲染)。**
43
+
44
+ ### 修复
45
+
46
+ - 设置面板不显示:前端 bundle 的四个 `profile` 分支都会提前 `return`,面板代码写在分支之后,
47
+ 命中任一分支就永远执行不到(`const` 未初始化,包裹调用会撞 TDZ 并被 catch 静默吞掉)。
48
+ 现在把面板定义提到分支之前,并在返回的模块上合并 `inject: ['slots']` 与面板的 `apply`,
49
+ 任何 profile 下都会挂上设置项。
50
+ - 开关样式改为与内置控件一致(轨道 `--dsw-alias-border-l1`、`on` 用 `--dsw-alias-brand-primary`、
51
+ 圆钮带阴影,左侧显示「已开启 / 已关闭」),此前半透明白轨道在一个深色主题下几乎看不见。
52
+
53
+ ### 文档
54
+
55
+ - README / README.en:DSH 徽章更新到 0.2.2-rc.3;补充终端入口 `reproxy-lan`(`status|enable|disable`)。
56
+
57
+ ---
58
+
59
+ ## 0.3.2(2026-11-15)
60
+
61
+ **一句话:默认只允许本机访问;要共享给局域网,必须在设置页或命令行里显式确认。**
62
+
63
+ ### 更新
64
+
65
+ - 新增「局域网访问」开关:设置页(设置 → 局域网访问)与命令行 `/lan yes|no|status` 两个入口,
66
+ 读写同一份状态文件 `<DSH_HOME>/plugin-reverse-proxy/lan-access.json`,切换后立即重建监听、重启保留。
67
+ - 监听地址不再由配置写死,改由开关状态决定:关闭 = `127.0.0.1`,开启 = `0.0.0.0`(含 IPv6 时 `::`)。
68
+ - 开启时启动日志打一条 `warn`,提醒同网段设备可直接进入后台。
69
+
70
+ ### 修复
71
+
72
+ - 安全:此前默认监听 `0.0.0.0:8080` 且免 Token 登录,装好即对局域网全开,且没有任何一次主动同意
73
+ (社区审核 fkysly 指出)。现在默认关闭,开启前必须过安全提示并确认。
74
+
75
+ ---
76
+
77
+ ## 0.3.1(2026-11-15)
78
+
79
+ **一句话:适配 DSH 0.2.2-rc.2 / rc.3,升级后免 Token 登录不再失效。**
80
+
81
+ ### 更新
82
+
83
+ - 兼容表 `carrier-neutral-v4` 新增 `0.2.2-rc.2`、`0.2.2-rc.3` 两个版本对(§5.15 审计)。
84
+ - 发布包不再把 `dist/*.tgz` 套进 tgz(避免 tgz 套 tgz 体积翻倍)。
85
+
86
+ ### 修复
87
+
88
+ - 升级到 DSH `0.2.2-rc.3` 后进入后台报 401「dsh web authentication required」:
89
+ 版本门控不认识新版本 → 免登录行休眠 → 官方 BrowserAuth 接管。
90
+
91
+ ---
92
+
93
+ ## 0.3.0(2026-11-13)
94
+
95
+ **一句话:反代加 gzip 与静态资源长缓存,弱网下 Web UI 首屏快一个数量级。**
96
+
97
+ ### 更新
98
+
99
+ - 文本类响应(JS / JSON / HTML / SVG / manifest)自动 gzip 压缩(`zlib.createGzip`,流式管道),
100
+ 首屏 JS 传输体积约降到原来的 1/3~1/4。
101
+ - `/assets/*` 与带 `rev=` 内容指纹的 `/plugins/*` 组合包返回
102
+ `cache-control: public, max-age=31536000, immutable`,二次访问不再重新下载。
103
+ - `text/event-stream`(SSE)、WebSocket、二进制与已压缩响应直通,不二次压缩。
104
+
105
+ ### 修复
106
+
107
+ - 手机弱网下首屏约 16MB 未压缩 JS 加载不完,导致「聊天记录不显示、刷新一直转圈」;
108
+ 电脑 LAN 下同样因为体积大而慢。
109
+
110
+ ---
111
+
112
+ ## 0.2.0(2026-11-11)
113
+
114
+ **一句话:反代插件把「免 Token 登录」吞了,一个包同时做两件事。**
115
+
116
+ ### 新增
117
+
118
+ - 合并免 Token 登录能力:替换官方 `@deepseek-ai/dsh-client-connection` 提供方,
119
+ 浏览器打开 Web 地址即可使用,不再需要从启动日志里复制 token。
120
+ - 免登录部分按「runtime 包 + connection 包」双锚点做精确版本门控,
121
+ 命中才替换,不命中自动休眠(官方行为原样保留,等价于没装)。
122
+ - 支持版本:`0.1.2-rc.1`、`0.1.5-rc.1/rc.2`、`0.1.7-rc.1/rc.2`、
123
+ `0.2.0-rc.1/rc.2`、`0.2.1-rc.1~rc.5`、`0.2.2-rc.1`。
124
+ - desktop 宿主一律休眠(按安装槽位 / 启动 argv / 宿主二进制三重判别),
125
+ 不会把桌面版带崩。
126
+ - 免登录源码内联在 `vendor/skip/`(参考 `@iasiv5/dsh-skip-browser-auth`,MIT,
127
+ 保留其 LICENSE / NOTICE)。
128
+
129
+ ### 修复
130
+
131
+ - 入口漏声明 `inject: ['webServer']`,导致替换 connection 后注册路由时报
132
+ `cannot get property "webServer" without inject`(0.2.0 第一次上线踩到,
133
+ 已修复并二次验证通过)。
134
+ - 启动流程改为「模块级 inject + 行级 inject 合并」:`webServer` 与
135
+ `webStartup` / `webRuntime` 同时注入,替换行与反代行都能正常拿到服务。
136
+
137
+ ### 文档
138
+
139
+ - README 重写:两个能力的原理图、适用范围表(Web UI ✅ / 桌面版 ❌)、
140
+ 配置项与 nginx 原配置对照、卸载与回退步骤、常见问题。
141
+ - 新增本 CHANGELOG。
142
+
143
+ ### 已知限制
144
+
145
+ - 仅 Web UI 版适用;桌面版/客户端用不上。
146
+ - 免登录依赖版本白名单:DSH 升级到白名单外的版本后会自动休眠,
147
+ 表现为「又需要 token 了」,不是故障。
148
+
149
+ ---
150
+
151
+ ## 0.1.0(2026-11-09)
152
+
153
+ **一句话:把 nginx 承担的 dsh 反向代理搬进插件。**
154
+
155
+ - 监听 `0.0.0.0:8080`,转发到 `127.0.0.1:3080`。
156
+ - 改写请求头以通过 dsh 的 Host/Origin 校验:
157
+ `Host: 127.0.0.1:3080`、`Origin: http://127.0.0.1:3080`、`Sec-Fetch-Site: same-origin`,
158
+ 清空 `Referer`,补 `X-Real-IP` / `X-Forwarded-For` / `X-Forwarded-Proto`。
159
+ - WebSocket 用 `net.connect` 手写 101 透传;响应不缓冲;请求体上限 200 MiB;
160
+ 端口占用每 5 秒重试;加载期异常不外抛(不会拖垮宿主)。
161
+ - 与 nginx 行为对齐验证:`/` 响应字节数、`/api` 302 行为、静态资源 sha256 均一致。
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 llifco
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.en.md ADDED
@@ -0,0 +1,234 @@
1
+ <p align="center">
2
+ <img src="assets/logo.jpg" width="132" alt="Da Fei Yu">
3
+ </p>
4
+
5
+ <h1 align="center">dsh-plugin-reverse-proxy</h1>
6
+
7
+ <p align="center"><a href="README.md">简体中文</a> | English</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
+ > One command and any device on your LAN — phone, tablet, another laptop — can open your DSH web UI,
20
+ > **without copying the random token out of the startup log**.
21
+
22
+ ---
23
+
24
+ ## Three capabilities
25
+
26
+ > Since 0.3.5: the settings switch is purple, and the **listening port** is editable
27
+ > (default 8080, applied on save, kept across restarts).
28
+
29
+ ### 1. Reverse proxy (on by default)
30
+
31
+ ```
32
+ LAN browser ──▶ 0.0.0.0:8080 (this plugin)
33
+ │ rewrite headers:
34
+ │ Host → 127.0.0.1:3080
35
+ │ Origin → http://127.0.0.1:3080
36
+ │ Sec-Fetch-Site → same-origin
37
+ │ Referer → cleared
38
+ │ plus: X-Real-IP / X-Forwarded-For / X-Forwarded-Proto
39
+ ▼
40
+ 127.0.0.1:3080 (dsh web itself)
41
+ ```
42
+
43
+ `dsh web` binds to loopback only and validates `Host` / `Origin`, so exposing it directly
44
+ returns 403. nginx used to rewrite those headers; now the plugin does.
45
+
46
+ - streaming, no buffering (SSE and large downloads stay smooth)
47
+ - WebSocket: hand-rolled 101 tunneling over `net.connect`
48
+ - 3600s long-connection timeout to match nginx; 200 MiB request body cap
49
+ - retries every 5s when the port is taken; never throws during load
50
+
51
+ ### 2. LAN access switch and port (off by default / 8080)
52
+
53
+ The proxy only listens on `127.0.0.1:8080` — reachable from **this machine only**.
54
+ To share the UI with a phone, tablet or another computer on the same Wi-Fi / LAN you must
55
+ explicitly turn it on through one of three entries, all backed by the same state file:
56
+
57
+ ```bash
58
+ # terminal
59
+ reproxy-lan status # show state
60
+ reproxy-lan enable # prints the warning, needs the word yes
61
+ reproxy-lan disable # turn off immediately
62
+ reproxy-lan port 9000 # change the listening port (1024-65535; 3080 is DSH's own)
63
+ ```
64
+
65
+ ```
66
+ /lan status /lan yes /lan no # or the slash command in the DSH input box
67
+ ```
68
+
69
+ or **Settings → 局域网访问 (LAN access)** → flip the switch → confirm the warning dialog.
70
+
71
+ Terminal example (`status` → `enable` → typing `yes` → listening on `0.0.0.0:8080`):
72
+
73
+ ![reproxy-lan in a terminal](assets/lan-access-cli.jpg)
74
+
75
+ ### Changing the port (default 8080)
76
+
77
+ The same settings page has a **port** field: type a number → **Save** → the listener is
78
+ rebuilt immediately (**no restart needed**) and the value survives restarts.
79
+ Rules: 1024–65535, never 3080 (that is DSH itself); an unavailable port returns 409 and
80
+ nothing changes.
81
+
82
+ ```
83
+ /lan port show the current port
84
+ /lan port 9000 change it (or `reproxy-lan port 9000` over SSH)
85
+ ```
86
+
87
+ State lives in `<DSH_HOME>/plugin-reverse-proxy/lan-access.json`
88
+ (`{"lanAccess": true, "port": 8080, ...}`), so it survives `systemctl restart dsh`;
89
+ edits to that file are picked up within a second (`fs.watch`).
90
+
91
+ > ⚠️ Once enabled, any device on the same network can open `http://<machine-ip>:8080` and get
92
+ > the full back end (sessions, terminal, settings) with no token and no login.
93
+ > Only enable it on a network you trust.
94
+
95
+ ---
96
+
97
+ ### 3. Token-free login (version-gated)
98
+
99
+ Replaces the official `@deepseek-ai/dsh-client-connection` provider and skips BrowserAuth.
100
+
101
+ - **web-only**: desktop hosts go dormant (process-tree detection), official behavior untouched
102
+ - **strict allowlist**: the runtime and connection packages must both match a known version,
103
+ otherwise it sleeps and the official connection row stays as-is
104
+ - **no patching of DSH itself**: only the official plugin patch mechanism is used; remove or
105
+ disable the plugin and everything is back
106
+ - covered: `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`
107
+
108
+ > Based on and partly inlined from [`@iasiv5/dsh-skip-browser-auth`](https://github.com/iasiv5/dsh-skip-browser-auth) (MIT),
109
+ > kept under `vendor/skip/` with its LICENSE and NOTICE.
110
+
111
+ ---
112
+
113
+ ## Scope
114
+
115
+ | Where | Supported |
116
+ |---|---|
117
+ | **Web UI** (`http://<LAN-IP>:8080`, port configurable, LAN access switch must be on) | ✅ what it is for |
118
+ | **Desktop / client app** | ❌ pointless there |
119
+
120
+ The desktop app runs locally and can hit `127.0.0.1:3080` directly — no proxy, no auth skip needed.
121
+
122
+ ---
123
+
124
+ ## Install
125
+
126
+ ```bash
127
+ git clone https://github.com/llifco/dsh-plugin-reverse-proxy.git
128
+ cd dsh-plugin-reverse-proxy
129
+ dsh plugin --profile web add .
130
+ ```
131
+
132
+ or install the tarball from the releases page:
133
+
134
+ ```bash
135
+ dsh plugin --profile web add ./dsh-plugin-reverse-proxy-0.3.3.tgz
136
+ ```
137
+
138
+ Restart the host once:
139
+
140
+ ```bash
141
+ systemctl restart dsh
142
+ ```
143
+
144
+ By default it listens on `127.0.0.1:8080` only, so first check `http://127.0.0.1:8080` locally.
145
+ To let other devices in, enable the LAN access switch (`reproxy-lan enable`, `/lan yes`, or
146
+ Settings → LAN access) and then open `http://<LAN-IP>:8080` — no token.
147
+
148
+ ---
149
+
150
+ ## Configuration
151
+
152
+ Reverse proxy (the `dsh-plugin-reverse-proxy` row in `cordis.patch.yml`):
153
+
154
+ | Key | Default | Former nginx directive |
155
+ |---|---|---|
156
+ | `listenHost` | decided by the LAN switch (default `127.0.0.1`) | `listen 127.0.0.1:8080` |
157
+ | `listenPort` | `8080` | same |
158
+ | `listenIpv6` | `false` | `listen [::]:8080` |
159
+ | `upstreamHost` / `upstreamPort` | `127.0.0.1` / `3080` | `proxy_pass` |
160
+ | `upstreamHostHeader` | `127.0.0.1:3080` | `proxy_set_header Host` |
161
+ | `upstreamOrigin` | `http://127.0.0.1:3080` | `proxy_set_header Origin` |
162
+ | `maxBodyBytes` | `209715200` | `client_max_body_size 200m` |
163
+ | `retryMs` | `5000` | — (port-conflict retry) |
164
+
165
+ `trustedHosts` for the token-free rows is injected by DSH's web runtime; usually no manual edit.
166
+
167
+ ---
168
+
169
+ ## Layout
170
+
171
+ ```
172
+ dsh-plugin-reverse-proxy/
173
+ ├── index.js # entry: dispatch by cordis row id (proxy / skip-auth)
174
+ ├── cordis.patch.yml # official patch: version gate + the capability rows
175
+ ├── assets/logo.jpg # repo avatar
176
+ ├── vendor/skip/ # token-free implementation (MIT, from dsh-skip-browser-auth)
177
+ │ ├── host.js gate.js compatibility.js
178
+ │ ├── trust-fence.js trusted-auth.js bridge.js
179
+ │ ├── connection-runtime.js
180
+ │ ├── adapters/ # carrier-neutral / -017 / -021
181
+ │ └── client.js # prebuilt browser bundle
182
+ ├── dist/*.tgz # packaged builds (offline install)
183
+ ├── CHANGELOG.md
184
+ ├── README.md / README.en.md
185
+ └── LICENSE
186
+ ```
187
+
188
+ ---
189
+
190
+ ## Uninstall / roll back to nginx
191
+
192
+ ```bash
193
+ dsh plugin --profile web remove dsh-plugin-reverse-proxy
194
+ systemctl restart dsh
195
+ ```
196
+
197
+ Back to nginx:
198
+
199
+ ```bash
200
+ ln -sf /etc/nginx/sites-available/dsh /etc/nginx/sites-enabled/dsh
201
+ nginx -t && systemctl reload nginx
202
+ ```
203
+
204
+ ---
205
+
206
+ ## FAQ
207
+
208
+ **Only this machine can open it; my phone cannot?**
209
+ That is the 0.3.2+ default (`127.0.0.1` only). Enable the switch — `reproxy-lan enable`,
210
+ `/lan yes`, or Settings → LAN access. `ss -ltnp | grep 8080` should then show `0.0.0.0:8080`.
211
+
212
+ **Port 8080 still dead after install?**
213
+ `ss -ltnp | grep 8080` — if nginx still owns it, the old `sites-enabled/dsh` symlink is still there.
214
+
215
+ **It asks for a token again?**
216
+ The skip-auth half went dormant, usually because DSH was upgraded past the allowlist.
217
+ Check the log for `BrowserAuth has been skipped`; absent means dormant (official behavior).
218
+
219
+ **Can it reach the internet?**
220
+ No, and it should not. It only makes LAN access work; add your own tunnel plus auth.
221
+
222
+ **Does the desktop app use it?**
223
+ No — connect to `127.0.0.1:3080` directly.
224
+
225
+ ---
226
+
227
+ ## Feedback
228
+
229
+ - Bugs / feature requests: **QQ 3538638569** (3538638569@qq.com)
230
+ - Include `dsh --version`, `dsh plugin --profile web list` and the relevant log lines.
231
+
232
+ ## License
233
+
234
+ MIT (`vendor/skip/` code comes from @iasiv5/dsh-skip-browser-auth, also MIT).