dsh-plugin-reverse-proxy 0.0.0-stage → 0.4.2
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 +225 -0
- package/LICENSE +21 -0
- package/README.en.md +265 -0
- package/README.md +297 -2
- package/assets/lan-access-cli.jpg +0 -0
- package/assets/logo.jpg +0 -0
- package/cordis.patch.yml +75 -0
- package/index.js +568 -0
- package/lan-access.js +164 -0
- package/package.json +59 -4
- package/vendor/skip/LICENSE +21 -0
- package/vendor/skip/NOTICE +41 -0
- package/vendor/skip/adapters/carrier-neutral-017.js +57 -0
- package/vendor/skip/adapters/carrier-neutral-021.js +92 -0
- package/vendor/skip/adapters/carrier-neutral.js +23 -0
- package/vendor/skip/adapters/legacy-web.js +6 -0
- package/vendor/skip/adapters/types.js +20 -0
- package/vendor/skip/bridge.js +122 -0
- package/vendor/skip/client.js +14576 -0
- package/vendor/skip/compatibility.js +223 -0
- package/vendor/skip/connection-runtime.js +63 -0
- package/vendor/skip/gate.js +176 -0
- package/vendor/skip/host.js +212 -0
- package/vendor/skip/multi-peer.js +141 -0
- package/vendor/skip/trust-fence.js +135 -0
- package/vendor/skip/trusted-auth.js +95 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
# 更新日志
|
|
2
|
+
|
|
3
|
+
本文件记录每个版本改了什么。格式:版本号(日期)先概述,再分条列具体改动。
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 0.4.2
|
|
8
|
+
|
|
9
|
+
### 文档 / 界面
|
|
10
|
+
- 设置页「局域网访问」面板底部新增一条常驻提示:**多窗口限制**——同一浏览器暂时只能开一个窗口,第二块会卡在加载,原因是 DSH 官方的身份模型(一个浏览器 = 一份连接、只接一条能回答的事件流),插件层绕不过去,等官方放开;手机与电脑各开一个、或其中一个用无痕窗口不受影响。
|
|
11
|
+
- README 中英 FAQ 同步改成「已知限制」,不再声称已修复;同时写明 0.4.x 已经把标签身份做进 `x-dsh-tab` / `?tab=`(日志可见),卡点在网关只认一条回答流。
|
|
12
|
+
|
|
13
|
+
## 0.4.1
|
|
14
|
+
|
|
15
|
+
**一句话:把「普通请求」也认到标签身份上——这才是多窗口卡住的真正断点。**
|
|
16
|
+
|
|
17
|
+
### 修复
|
|
18
|
+
- 0.4.0 的诊断日志给出了答案:`http tab` / `http 无标签身份` **一条都没有**,说明普通请求根本没有走身份判定。原因是免 Token 模式下官方 `admit()` 里 `browserAuth.isAuthenticated()` 恒真,所有请求直接落到共享的 `browserPeer`;而事件流(waterfall)要求「回答必须来自持有该流的同一份 Peer」,`browserPeer` 手上没有 socket,请求于是永远挂起。
|
|
19
|
+
- 现在接管 `admit(request)`:带 `x-dsh-tab`(或 `?tab=`)的请求交给该标签自己的 Peer,与它的 mux 复用同一份;认不到标签才退回官方共享 Peer。
|
|
20
|
+
- mux 改成引用计数:同一标签的多条 socket 挂在同一份 Peer 上,全部断开才 dispose(0.3.x 里「新连接顶掉旧 Peer、旧 Peer 泄漏」一并解决)。
|
|
21
|
+
- 日志变清爽:`mux admit <tab> | 该标签 socket 数: N | 活跃 Peer: M`、`http tab <id> <path>`(每分钟每对去重)。
|
|
22
|
+
|
|
23
|
+
## 0.4.0
|
|
24
|
+
|
|
25
|
+
### 修复 / 诊断
|
|
26
|
+
- 0.3.9 之后两块窗口确实拿到了不同 id(日志 `tab-mwm0` / `tab-mwm1`),但第二块仍然卡在首屏,说明身份只是链条的第一环。
|
|
27
|
+
- 增加诊断日志(每分钟每个(标签, 路径)/(无标签, 路径)各一条):
|
|
28
|
+
- `http tab <id> /api/…`:带标签身份的普通请求;
|
|
29
|
+
- `http 无标签身份 /api/…`:**没带** `x-dsh-tab` 的请求(说明有代码路径绕过了签名,嫌疑最大)。
|
|
30
|
+
- 修 Peer 账目:同一标签反复重连时旧记录被新记录顶掉,旧记录的 release 找不到自己、Peer 永不回收(日志里「活跃 Peer」只涨不跌就是这个);现在 release 会按记录自身清理。
|
|
31
|
+
|
|
32
|
+
## 0.3.9
|
|
33
|
+
|
|
34
|
+
### 修复
|
|
35
|
+
- 0.3.8 之后两个标签仍拿到同一个身份:浏览器在「复制标签 / 从已有标签打开链接」时会把 `sessionStorage` 整份复制给新标签,于是两边的 `dsh-reproxy-tab` 完全一样(日志里 `mux admit tab-mwm0…` 两次同 id 就是它)。
|
|
36
|
+
- 改成只放在内存里、每个文档生成一次:一次页面加载 = 一个身份,复制标签/新开标签必然不同。刷新页面会换新 id(旧 Peer 随旧连接释放,不影响使用)。
|
|
37
|
+
|
|
38
|
+
## 0.3.8
|
|
39
|
+
|
|
40
|
+
**一句话:把身份粒度从「一个浏览器」改成「一个标签页」,同一设备可以同时开多个窗口。**
|
|
41
|
+
|
|
42
|
+
### 修复
|
|
43
|
+
- 0.3.7 之后多窗口仍卡:官方 `/connect` 的身份模型是「一个浏览器 cookie = 一个 Peer = 一条能回答 waterfall 的事件流」,同一浏览器的标签共享 cookie,第二个标签永远抢不到那条流,首屏请求等不到回答,页面一直转圈(断网重连能救回来,因为重连走了另一条路径)。
|
|
44
|
+
- 浏览器半边:每个标签页在 `sessionStorage` 里生成专属 id(不跨标签共享),`fetch` 加 `x-dsh-tab` 头、`WebSocket` 加 `?tab=`;挂不上或异常时静默退回原样,不影响单窗口。
|
|
45
|
+
- 主机半边:`multi-peer.js` 按标签 id 分配 Peer(HTTP 一元调用与 mux 复用同一份),断开即回收;认不到标签 id 时完全退回官方共享 Peer 行为。
|
|
46
|
+
|
|
47
|
+
## 0.3.7
|
|
48
|
+
|
|
49
|
+
### 修复
|
|
50
|
+
- 多窗口仍卡住:0.3.6 在铸造新 Peer 之前先走了官方 `admitConnection()`,共享 Peer 的 `ownsSocket` 被第一块窗口占住,第二块窗口直接吃到 409、客户端无限重连(表现就是一直转圈)。现在先做信任判定、再铸 Peer,不再碰共享 Peer 的 socket 归属。
|
|
51
|
+
- 增加多窗口诊断日志:每条 mux 连接的 admit/release、interactions 声明、活跃 Peer 数,以及被拒原因。
|
|
52
|
+
|
|
53
|
+
## 0.3.6(2026-11-18)
|
|
54
|
+
|
|
55
|
+
**一句话:同一台设备开第二个窗口不再抢不到后台——每条连接各拿一份独立会话。**
|
|
56
|
+
|
|
57
|
+
### 修复
|
|
58
|
+
|
|
59
|
+
- 同一设备开着第一个窗口、再开第二个窗口时,页面资源与聊天记录都加载不出来,必须把设备上所有窗口关掉才能恢复。
|
|
60
|
+
根因:免 Token 模式没有身份层,`browserAuth.isAuthenticated()` 恒真 ⇒ 所有浏览器请求共用同一个 `browserPeer`,
|
|
61
|
+
而一个 Peer 只服务它绑定的那条 mux 流;第二个窗口接上时两条流抢同一个 Peer,后开的就一直等不到响应。
|
|
62
|
+
现在每条 mux 连接在准入时现铸一份 Peer(principal 仍是 owner,`interactions` 沿用客户端在 `/connect` 里声明的值),
|
|
63
|
+
连接结束时释放——等价于官方「换一个浏览器 = 换一个会话」,只是把「浏览器」换成「连接」。
|
|
64
|
+
|
|
65
|
+
### 更新
|
|
66
|
+
|
|
67
|
+
- 启动日志多一行 `[reproxy-lan] per-socket peers enabled (multi-window)`,便于确认这段逻辑生效。
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## 0.3.5(2026-11-17)
|
|
72
|
+
|
|
73
|
+
**一句话:设置页的开关换成紫色,并新增「监听端口」输入框(保存即生效、重启保留)。**
|
|
74
|
+
|
|
75
|
+
### 更新
|
|
76
|
+
|
|
77
|
+
- 设置页「局域网访问」开关改用紫色(`#8b5cf6`)+ 白色圆钮,深色主题下更显眼。
|
|
78
|
+
- 新增「监听端口」输入框:默认 8080,允许 1024–65535,改完点「保存」立即重建监听(不用重启 dsh),重启后保留。
|
|
79
|
+
- 端口也进状态文件 `<DSH_HOME>/plugin-reverse-proxy/lan-access.json` 的 `port` 字段;设置页、斜杠命令、命令行三个入口读写同一份。
|
|
80
|
+
- `POST /reproxy-lan/port` 新接口:先探测端口是否被占(被占返回 409),再写入并重建监听。
|
|
81
|
+
- 斜杠命令扩展:`/lan port` 看当前端口、`/lan port 9000` 直接改。
|
|
82
|
+
- `GET /reproxy-lan/status` 多返回 `defaultPort`,方便前端显示默认值。
|
|
83
|
+
|
|
84
|
+
### 修复
|
|
85
|
+
|
|
86
|
+
- 端口从未真正生效过(`normalize()` 一直读配置里的 8080),现在以状态文件为准。
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## 0.3.4(2026-11-15)
|
|
91
|
+
|
|
92
|
+
**一句话:只打包文档,把 0.3.x 的用法和截图一起塞进发行包(代码与 0.3.3 相同)。**
|
|
93
|
+
|
|
94
|
+
### 文档
|
|
95
|
+
|
|
96
|
+
- README / README.en:新增「局域网访问」完整用法(设置页开关、`/lan` 斜杠命令、
|
|
97
|
+
终端 `reproxy-lan status|enable|disable`)、状态文件说明、终端示例截图 `assets/lan-access-cli.jpg`。
|
|
98
|
+
- 明确默认只监听 `127.0.0.1:8080`;安装段、适用范围与 FAQ 同步补「要开开关才对外」。
|
|
99
|
+
- 免 Token 登录覆盖版本补 `0.2.2-rc.2/rc.3`;目录结构补 `lan-access.js`。
|
|
100
|
+
- `package.json` 的 `files` 增加 `assets`、`README.en.md`,保证包内 README 的图片能正常显示。
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## 0.3.3(2026-11-15)
|
|
105
|
+
|
|
106
|
+
**一句话:设置页里的「局域网访问」开关真的会出现了(0.3.2 的入口实际没渲染)。**
|
|
107
|
+
|
|
108
|
+
### 修复
|
|
109
|
+
|
|
110
|
+
- 设置面板不显示:前端 bundle 的四个 `profile` 分支都会提前 `return`,面板代码写在分支之后,
|
|
111
|
+
命中任一分支就永远执行不到(`const` 未初始化,包裹调用会撞 TDZ 并被 catch 静默吞掉)。
|
|
112
|
+
现在把面板定义提到分支之前,并在返回的模块上合并 `inject: ['slots']` 与面板的 `apply`,
|
|
113
|
+
任何 profile 下都会挂上设置项。
|
|
114
|
+
- 开关样式改为与内置控件一致(轨道 `--dsw-alias-border-l1`、`on` 用 `--dsw-alias-brand-primary`、
|
|
115
|
+
圆钮带阴影,左侧显示「已开启 / 已关闭」),此前半透明白轨道在一个深色主题下几乎看不见。
|
|
116
|
+
|
|
117
|
+
### 文档
|
|
118
|
+
|
|
119
|
+
- README / README.en:DSH 徽章更新到 0.2.2-rc.3;补充终端入口 `reproxy-lan`(`status|enable|disable`)。
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## 0.3.2(2026-11-15)
|
|
124
|
+
|
|
125
|
+
**一句话:默认只允许本机访问;要共享给局域网,必须在设置页或命令行里显式确认。**
|
|
126
|
+
|
|
127
|
+
### 更新
|
|
128
|
+
|
|
129
|
+
- 新增「局域网访问」开关:设置页(设置 → 局域网访问)与命令行 `/lan yes|no|status` 两个入口,
|
|
130
|
+
读写同一份状态文件 `<DSH_HOME>/plugin-reverse-proxy/lan-access.json`,切换后立即重建监听、重启保留。
|
|
131
|
+
- 监听地址不再由配置写死,改由开关状态决定:关闭 = `127.0.0.1`,开启 = `0.0.0.0`(含 IPv6 时 `::`)。
|
|
132
|
+
- 开启时启动日志打一条 `warn`,提醒同网段设备可直接进入后台。
|
|
133
|
+
|
|
134
|
+
### 修复
|
|
135
|
+
|
|
136
|
+
- 安全:此前默认监听 `0.0.0.0:8080` 且免 Token 登录,装好即对局域网全开,且没有任何一次主动同意
|
|
137
|
+
(社区审核 fkysly 指出)。现在默认关闭,开启前必须过安全提示并确认。
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## 0.3.1(2026-11-15)
|
|
142
|
+
|
|
143
|
+
**一句话:适配 DSH 0.2.2-rc.2 / rc.3,升级后免 Token 登录不再失效。**
|
|
144
|
+
|
|
145
|
+
### 更新
|
|
146
|
+
|
|
147
|
+
- 兼容表 `carrier-neutral-v4` 新增 `0.2.2-rc.2`、`0.2.2-rc.3` 两个版本对(§5.15 审计)。
|
|
148
|
+
- 发布包不再把 `dist/*.tgz` 套进 tgz(避免 tgz 套 tgz 体积翻倍)。
|
|
149
|
+
|
|
150
|
+
### 修复
|
|
151
|
+
|
|
152
|
+
- 升级到 DSH `0.2.2-rc.3` 后进入后台报 401「dsh web authentication required」:
|
|
153
|
+
版本门控不认识新版本 → 免登录行休眠 → 官方 BrowserAuth 接管。
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## 0.3.0(2026-11-13)
|
|
158
|
+
|
|
159
|
+
**一句话:反代加 gzip 与静态资源长缓存,弱网下 Web UI 首屏快一个数量级。**
|
|
160
|
+
|
|
161
|
+
### 更新
|
|
162
|
+
|
|
163
|
+
- 文本类响应(JS / JSON / HTML / SVG / manifest)自动 gzip 压缩(`zlib.createGzip`,流式管道),
|
|
164
|
+
首屏 JS 传输体积约降到原来的 1/3~1/4。
|
|
165
|
+
- `/assets/*` 与带 `rev=` 内容指纹的 `/plugins/*` 组合包返回
|
|
166
|
+
`cache-control: public, max-age=31536000, immutable`,二次访问不再重新下载。
|
|
167
|
+
- `text/event-stream`(SSE)、WebSocket、二进制与已压缩响应直通,不二次压缩。
|
|
168
|
+
|
|
169
|
+
### 修复
|
|
170
|
+
|
|
171
|
+
- 手机弱网下首屏约 16MB 未压缩 JS 加载不完,导致「聊天记录不显示、刷新一直转圈」;
|
|
172
|
+
电脑 LAN 下同样因为体积大而慢。
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## 0.2.0(2026-11-11)
|
|
177
|
+
|
|
178
|
+
**一句话:反代插件把「免 Token 登录」吞了,一个包同时做两件事。**
|
|
179
|
+
|
|
180
|
+
### 新增
|
|
181
|
+
|
|
182
|
+
- 合并免 Token 登录能力:替换官方 `@deepseek-ai/dsh-client-connection` 提供方,
|
|
183
|
+
浏览器打开 Web 地址即可使用,不再需要从启动日志里复制 token。
|
|
184
|
+
- 免登录部分按「runtime 包 + connection 包」双锚点做精确版本门控,
|
|
185
|
+
命中才替换,不命中自动休眠(官方行为原样保留,等价于没装)。
|
|
186
|
+
- 支持版本:`0.1.2-rc.1`、`0.1.5-rc.1/rc.2`、`0.1.7-rc.1/rc.2`、
|
|
187
|
+
`0.2.0-rc.1/rc.2`、`0.2.1-rc.1~rc.5`、`0.2.2-rc.1`。
|
|
188
|
+
- desktop 宿主一律休眠(按安装槽位 / 启动 argv / 宿主二进制三重判别),
|
|
189
|
+
不会把桌面版带崩。
|
|
190
|
+
- 免登录源码内联在 `vendor/skip/`(参考 `@iasiv5/dsh-skip-browser-auth`,MIT,
|
|
191
|
+
保留其 LICENSE / NOTICE)。
|
|
192
|
+
|
|
193
|
+
### 修复
|
|
194
|
+
|
|
195
|
+
- 入口漏声明 `inject: ['webServer']`,导致替换 connection 后注册路由时报
|
|
196
|
+
`cannot get property "webServer" without inject`(0.2.0 第一次上线踩到,
|
|
197
|
+
已修复并二次验证通过)。
|
|
198
|
+
- 启动流程改为「模块级 inject + 行级 inject 合并」:`webServer` 与
|
|
199
|
+
`webStartup` / `webRuntime` 同时注入,替换行与反代行都能正常拿到服务。
|
|
200
|
+
|
|
201
|
+
### 文档
|
|
202
|
+
|
|
203
|
+
- README 重写:两个能力的原理图、适用范围表(Web UI ✅ / 桌面版 ❌)、
|
|
204
|
+
配置项与 nginx 原配置对照、卸载与回退步骤、常见问题。
|
|
205
|
+
- 新增本 CHANGELOG。
|
|
206
|
+
|
|
207
|
+
### 已知限制
|
|
208
|
+
|
|
209
|
+
- 仅 Web UI 版适用;桌面版/客户端用不上。
|
|
210
|
+
- 免登录依赖版本白名单:DSH 升级到白名单外的版本后会自动休眠,
|
|
211
|
+
表现为「又需要 token 了」,不是故障。
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## 0.1.0(2026-11-09)
|
|
216
|
+
|
|
217
|
+
**一句话:把 nginx 承担的 dsh 反向代理搬进插件。**
|
|
218
|
+
|
|
219
|
+
- 监听 `0.0.0.0:8080`,转发到 `127.0.0.1:3080`。
|
|
220
|
+
- 改写请求头以通过 dsh 的 Host/Origin 校验:
|
|
221
|
+
`Host: 127.0.0.1:3080`、`Origin: http://127.0.0.1:3080`、`Sec-Fetch-Site: same-origin`,
|
|
222
|
+
清空 `Referer`,补 `X-Real-IP` / `X-Forwarded-For` / `X-Forwarded-Proto`。
|
|
223
|
+
- WebSocket 用 `net.connect` 手写 101 透传;响应不缓冲;请求体上限 200 MiB;
|
|
224
|
+
端口占用每 5 秒重试;加载期异常不外抛(不会拖垮宿主)。
|
|
225
|
+
- 与 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,265 @@
|
|
|
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
|
+

|
|
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
|
+
**From npm (easiest; also listed in awesome-dsh-plugin)**
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
dsh plugin --profile web add dsh-plugin-reverse-proxy
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
or search `reverse-proxy` in the plugin marketplace and hit Install.
|
|
133
|
+
|
|
134
|
+
**From source**
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
git clone https://github.com/llifco/dsh-plugin-reverse-proxy.git
|
|
138
|
+
cd dsh-plugin-reverse-proxy
|
|
139
|
+
dsh plugin --profile web add .
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
or use the tarball from the releases page / npm (filename carries the current version):
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
dsh plugin --profile web add ./dsh-plugin-reverse-proxy-0.3.5.tgz
|
|
146
|
+
# or: https://registry.npmjs.org/dsh-plugin-reverse-proxy/-/dsh-plugin-reverse-proxy-0.3.5.tgz
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Restart the host once:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
systemctl restart dsh
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
By default it listens on `127.0.0.1:8080` only, so first check `http://127.0.0.1:8080` locally.
|
|
156
|
+
To let other devices in, enable the LAN access switch (`reproxy-lan enable`, `/lan yes`, or
|
|
157
|
+
Settings → LAN access) and then open `http://<LAN-IP>:8080` — no token.
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## Configuration
|
|
162
|
+
|
|
163
|
+
Reverse proxy (the `dsh-plugin-reverse-proxy` row in `cordis.patch.yml`):
|
|
164
|
+
|
|
165
|
+
| Key | Default | Former nginx directive |
|
|
166
|
+
|---|---|---|
|
|
167
|
+
| `listenHost` | decided by the LAN switch (default `127.0.0.1`) | `listen 127.0.0.1:8080` |
|
|
168
|
+
| `listenPort` | `8080` | same |
|
|
169
|
+
| `listenIpv6` | `false` | `listen [::]:8080` |
|
|
170
|
+
| `upstreamHost` / `upstreamPort` | `127.0.0.1` / `3080` | `proxy_pass` |
|
|
171
|
+
| `upstreamHostHeader` | `127.0.0.1:3080` | `proxy_set_header Host` |
|
|
172
|
+
| `upstreamOrigin` | `http://127.0.0.1:3080` | `proxy_set_header Origin` |
|
|
173
|
+
| `maxBodyBytes` | `209715200` | `client_max_body_size 200m` |
|
|
174
|
+
| `retryMs` | `5000` | — (port-conflict retry) |
|
|
175
|
+
|
|
176
|
+
`trustedHosts` for the token-free rows is injected by DSH's web runtime; usually no manual edit.
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## Layout
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
dsh-plugin-reverse-proxy/
|
|
184
|
+
├── index.js # entry: dispatch by cordis row id (proxy / skip-auth)
|
|
185
|
+
├── cordis.patch.yml # official patch: version gate + the capability rows
|
|
186
|
+
├── assets/logo.jpg # repo avatar
|
|
187
|
+
├── vendor/skip/ # token-free implementation (MIT, from dsh-skip-browser-auth)
|
|
188
|
+
│ ├── host.js gate.js compatibility.js
|
|
189
|
+
│ ├── trust-fence.js trusted-auth.js bridge.js
|
|
190
|
+
│ ├── connection-runtime.js
|
|
191
|
+
│ ├── adapters/ # carrier-neutral / -017 / -021
|
|
192
|
+
│ └── client.js # prebuilt browser bundle
|
|
193
|
+
├── dist/*.tgz # packaged builds (offline install)
|
|
194
|
+
├── CHANGELOG.md
|
|
195
|
+
├── README.md / README.en.md
|
|
196
|
+
└── LICENSE
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Uninstall / roll back to nginx
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
dsh plugin --profile web remove dsh-plugin-reverse-proxy
|
|
205
|
+
systemctl restart dsh
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Back to nginx:
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
ln -sf /etc/nginx/sites-available/dsh /etc/nginx/sites-enabled/dsh
|
|
212
|
+
nginx -t && systemctl reload nginx
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## FAQ
|
|
218
|
+
|
|
219
|
+
**Only this machine can open it; my phone cannot?**
|
|
220
|
+
That is the 0.3.2+ default (`127.0.0.1` only). Enable the switch — `reproxy-lan enable`,
|
|
221
|
+
`/lan yes`, or Settings → LAN access. `ss -ltnp | grep 8080` should then show `0.0.0.0:8080`.
|
|
222
|
+
|
|
223
|
+
**Port 8080 still dead after install?**
|
|
224
|
+
`ss -ltnp | grep 8080` — if nginx still owns it, the old `sites-enabled/dsh` symlink is still there.
|
|
225
|
+
|
|
226
|
+
**It asks for a token again?**
|
|
227
|
+
The skip-auth half went dormant, usually because DSH was upgraded past the allowlist.
|
|
228
|
+
Check the log for `BrowserAuth has been skipped`; absent means dormant (official behavior).
|
|
229
|
+
|
|
230
|
+
**Can it reach the internet?**
|
|
231
|
+
No, and it should not. It only makes LAN access work; add your own tunnel plus auth.
|
|
232
|
+
|
|
233
|
+
**Does the desktop app use it?**
|
|
234
|
+
No — connect to `127.0.0.1:3080` directly.
|
|
235
|
+
|
|
236
|
+
**Q: Opening a second window on the same device shows a blank page and no chat history?**
|
|
237
|
+
|
|
238
|
+
Fixed in 0.3.6. Without an identity layer every browser request shares one
|
|
239
|
+
`browserPeer`, and a Peer serves only the stream bound to it — the second
|
|
240
|
+
window's stream competed for the same endpoints and waited forever until every
|
|
241
|
+
window was closed. Each mux connection now mints its own Peer. Look for
|
|
242
|
+
`[reproxy-lan] per-socket peers enabled (multi-window)` in the log to confirm.
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## Feedback
|
|
247
|
+
|
|
248
|
+
- Bugs / feature requests: **QQ 3538638569** (3538638569@qq.com)
|
|
249
|
+
- Include `dsh --version`, `dsh plugin --profile web list` and the relevant log lines.
|
|
250
|
+
|
|
251
|
+
## License
|
|
252
|
+
|
|
253
|
+
MIT (`vendor/skip/` code comes from @iasiv5/dsh-skip-browser-auth, also MIT).
|
|
254
|
+
|
|
255
|
+
**Q: A second tab on the same device stays on a spinner?**
|
|
256
|
+
|
|
257
|
+
**Known limitation: multiple tabs of the same browser are not supported yet.** The second tab
|
|
258
|
+
spins forever and shows an empty session list; closing the other tabs (or a network reconnect)
|
|
259
|
+
recovers it. One tab per device, or one of them in a private window, works fine.
|
|
260
|
+
|
|
261
|
+
Cause is upstream: one browser cookie = one Peer = one answering event stream, and the gateway
|
|
262
|
+
routes events to the single live client rather than per tab. 0.4.x already gives each tab its own
|
|
263
|
+
identity (`x-dsh-tab` header plus `?tab=` on the mux — visible as `http tab ...` / `mux admit ...`
|
|
264
|
+
in the log), but the gateway still accepts only one answering stream, so the plugin cannot work
|
|
265
|
+
around it.
|