dsh-lan-access
August 16, 2026 · View on GitHub
dsh-lan-access
Open the DeepSeek Harness (dsh) web UI from any device on your WiFi — zero install on clients.
在已部署 dsh 的 Android 手机(Termux)上,让同一 WiFi 的平板 / 电脑 / 手机用浏览器直接完整使用 dsh:看到手机上的对话、能改设置、能建工作区。
Why / 为什么需要它
dsh 的 web UI 是单设备设计,局域网访问被三层障碍挡住:
| # | 障碍 | 现象 | 解法 |
|---|---|---|---|
| 1 | 客户端 isLoopback 门 | LAN 打开页面只调 inventory 同步(value:[]),数据 API 一个不发,UI 卡"正在加载工作区" | 源码补丁强制 isLoopback: true |
| 2 | 服务端特权围栏(PRIVILEGED_METHODS) | 设置 / 凭据 / 建工作区 403 | 3 处放开为 this.trustedHosts |
| 3 | 🔑 crypto.randomUUID 缺失(真凶) | LAN 的 http://<IP>:3088 是非安全上下文,crypto.randomUUID() 不存在 → RPC 全崩 → WS 反复 closed before established | 代理向 HTML <head> 注入 polyfill |
只测 curl = 假阳性(API 200 但 UI 罢工),必须用真浏览器验证(见 完整版教程 第五节)。
📚 教程 Tutorials(从这里开始)
| 教程 | 适合谁 | 内容 | 阅读时间 |
|---|---|---|---|
| ⚡ 快速上手 · Quick Start Guide | 已装好 dsh,想立刻能用 | 精简版:部署命令 + 使用 + 排查速查 + 安全与回滚 | 3 分钟 |
| 📖 完整版 · Full Tutorial | 想彻底搞懂原理 / 关注安全 | 完整版:三大障碍原理 + 双层加固设计 + 安全影响评估 + 彻底卸载回滚 + 文件速查 | 10 分钟 |
五分钟上手:看快速上手 → 复制命令 → 浏览器打开
http://<手机IP>:3088即可。 遇到问题先查快速上手「排查速查」;还不行看完整版原理章节定位。
Architecture / 架构
Client browser ──> http://<phone-ip>:3088
│
▼
┌──────────────────────────────┐
│ dsh-lan-proxy.js (0.0.0.0:3088) │ on phone (Termux)
│ ① LAN switch ~/.dsh-lan-on │
│ ② Host/Origin → loopback │
│ ③ inject crypto.randomUUID │
└──────────────┬───────────────┘
▼
dsh web (127.0.0.1:3080)
| Port | Process | Listens | Purpose |
|---|---|---|---|
| 3080 | dsh web | 127.0.0.1 | dsh itself (CLI forbids --host 0.0.0.0) |
| 3088 | dsh-lan-proxy.js | 0.0.0.0 | LAN entry: forward + loopback rewrite + polyfill |
| 3090 | dsh-llm-proxy.js | 127.0.0.1 | optional LLM gateway adapter |
| 3098 | dsh-ctl-server.js | 127.0.0.1 | control API (LAN switch / restart / status) |
Quick Start / 快速开始
Prereq: dsh already installed & working in Termux; adb available for deployment.
# 1. copy the bundle to your phone (must use `cat >`, cp writes 0-byte under run-as)
adb push dsh-lan-proxy.js dsh-ctl-server.js start-dsh.sh rebrain.sh dsh-supervise.sh /sdcard/Download/
adb shell "run-as com.termux sh -c '
for f in dsh-lan-proxy.js dsh-ctl-server.js start-dsh.sh rebrain.sh dsh-supervise.sh; do
cat /sdcard/Download/\$f > /data/data/com.termux/files/home/dsh-brain-swap/\$f
done
rm -f /sdcard/Download/dsh-lan-proxy.js /sdcard/Download/dsh-ctl-server.js /sdcard/Download/start-dsh.sh /sdcard/Download/rebrain.sh /sdcard/Download/dsh-supervise.sh
'"
# 2. apply patches (idempotent) + start the chain
adb shell "run-as com.termux sh -c '
pkill -f \"[d]sh-supervise[.]sh\" 2>/dev/null
sleep 1
REBRAIN_NO_LAUNCH=1 sh /data/data/com.termux/files/home/dsh-brain-swap/rebrain.sh
'"
adb shell "run-as com.termux sh -c '
setsid sh /data/data/com.termux/files/home/dsh-brain-swap/dsh-supervise.sh \
> /data/data/com.termux/files/home/dsh-supervise.log 2>&1 < /dev/null &
'"
sleep 40
# 3. verify: 4 ports + phone IP
adb shell "run-as com.termux sh -c '
export PATH=/data/data/com.termux/files/usr/bin:\$PATH
for p in 3080 3088 3090 3098; do curl -s -m 2 -o /dev/null -w \"\$p=%{http_code} \" http://127.0.0.1:\$p/; done
echo; ip route get 1 | grep -oE \"src [0-9.]+\" | cut -d\" \" -f2
'"
Then open http://<phone-ip>:3088 from any device on the same WiFi.
- ⚡ 快速上手(部署+排查速查):docs/tutorial-quickstart.md
- 📖 完整版(原理+安全+回滚):docs/tutorial-full.md
Files / 文件说明
| File | Purpose |
|---|---|
dsh-lan-proxy.js | LAN proxy (switch + loopback rewrite + polyfill) — the core |
dsh-ctl-server.js | control API :3098 |
start-dsh.sh | launch chain (auto-detect IP) |
rebrain.sh | idempotent patch re-applier + deployer |
dsh-supervise.sh | keep-alive supervisor (restart in 5s) |
99-dsh.sh / dsh-start.sh | Termux:Boot autostart / widget shortcut |
dsh-llm-proxy.js settings.yaml cordis.patch.yml | optional LLM gateway adapter |
sandbox-shim.js | ⚠️ unconfined sandbox shim (see warnings) |
⚠️ Security / 安全警告
- LAN switch ON = any device on the WiFi can use dsh (read chats, change settings, run tasks on the phone). Use only on trusted home WiFi; keep the switch off on public/office networks. Delete
~/.dsh-lan-onto disable. sandbox-shim.jsruns the agent unconfined on the real device — remove it unless you understand the risk.start-dsh.shreads the upstream API key fromSENSENOVA_API_KEYenv — never commit a real key.- This is a community, third-party project, not affiliated with dsh. Patches are independent adaptations of runtime files; re-run
rebrain.shafter any dsh upgrade to re-apply them.
🙏 致谢 Acknowledgements
本项目站在巨人的肩膀上:
- DeepSeek Harness (dsh) —— 出色的本地 AI 智能体框架,本项目的服务端本体。所有补丁均为对运行文件的独立适配,不修改其任何版权代码;官方升级后重跑
rebrain.sh即可重打。 - Termux 与 Termux:Boot —— 本项目依赖的 Android 终端环境与开机自启机制。
- 商汤 SenseNova —— 提供 OpenAI 兼容网关(可选上游)。
- 特别感谢本项目的测试与反馈者。
🔗 友情链接 Friends & Links
| 项目 | 链接 | 说明 |
|---|---|---|
| DeepSeek Harness (dsh) | https://github.com/deepseek-ai/dsh | 服务端本体 |
| Termux | https://github.com/termux/termux-app | Android 终端模拟器 |
| Termux:Boot | https://github.com/termux/termux-boot | 开机自启支持 |
| puppeteer | https://github.com/puppeteer/puppeteer | 教程验证章节使用的浏览器自动化工具 |
你有同类项目(dsh 增强 / Termux 工具 / 局域网访问方案)想互链?开一个 Issue 提交即可,我会添加进来。