rice-awa/dsh-lan-gateway1

@dsh-external/dsh-lan-gateway

LAN/internet reverse-proxy gateway for the DeepSeek Harness web GUI: binds 0.0.0.0, forwards to the loopback dsh web server with header rewrite to pass the /api trust fence. LAN sources are password-free; non-LAN sources get a login page + HMAC cookie. Optional TLS with auto-generated self-signed or user-supplied certificates, and a Settings → Plugins card for live adjustment of port, CIDRs, auth, and TLS. Includes an insecure-origin UUID shim client bundle: on gateway-served plain-HTTP origins browsers lack crypto.randomUUID, so the client half patches a getRandomValues-backed randomUUID onto the Crypto prototype, fixing workspace open over LAN without touching DSH source.

包名
@dsh-external/dsh-lan-gateway
版本
0.3.0
许可证
MIT
最近更新
2026年8月16日

安装

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:rice-awa/dsh-lan-gateway

方式 A:使用官方 CLI 安装


## 使用

```bash

## 配置项(bundle patch / `--patch` 覆盖,或官方设置页)

所有可调项都同时暴露为 `lan-gateway` 用户设置命名空间:打开 **DSH 的 Settings → Plugins
→ 可配置插件**,展开「LAN 网关」卡片即可修改,保存即生效(监听器会按新配置自动重启)。
下表即卡片字段 / 配置键:

| 键 | 默认值 | 说明 |
| --- | --- | --- |
| `enabled` | `false` | 是否在启动时监听网络端口 |
| `gatewayPort` | `3081` | 网关监听端口(`0.0.0.0`) |
| `dshTargetPort` | 跟随 `ctx.webServer.port` | 转发到的 dsh loopback 端口 |
| `lanCidrs` | RFC1918 + link-local(见下) | 免密的受信 LAN 网段(逗号分隔) |
| `authRequired` | `true` | 非 LAN 来源是否需要登录 |
| `cookieMaxAgeDays` | `7` | 会话 cookie 有效期(天) |
| `cookieName` | `dsh_gw_auth` | 会话 cookie 名(不进卡片) |
| `tlsEnabled` | `false` | 是否以 HTTPS(TLS)提供服务 |
| `tlsMode` | `self-signed` | 证书来源:`self-signed` 自动生成 / `custom` 用自己的证书 |
| `tlsSelfSignedHosts` | `localhost` | 自签名证书的 SAN(逗号分隔的域名 / IP) |
| `tlsCertPath` | — | `custom` 模式:PEM 证书(或证书链)绝对路径 |
| `tlsKeyPath` | — | `custom` 模式:PEM 私钥绝对路径 |
| `tlsCertMaxAgeDays` | `825` | 自签名证书有效期(天) |

自签名证书在**首次启用 TLS 时生成一次**,持久化于 `~/.dsh/lan-gateway/tls/`
(`selfsigned.crt` / `selfsigned.key`,0600),之后重启复用同一张证书;
`lan_gateway tls-regenerate` 可随时换发新证书(新密钥)并热重启监听器。
配置示例(`--patch`):

```yaml
- id: dsh-lan-gateway
  config:
    enabled: true
    gatewayPort: 8443
    tlsEnabled: true
    tlsMode: self-signed
    tlsSelfSignedHosts: localhost, 192.168.1.5

或用自己的证书(例如 /etc/letsencrypt/live/example.com/ 下签发的 PEM):

- id: dsh-lan-gateway
  config:
    tlsEnabled: true
    tlsMode: custom
    tlsCertPath: /etc/letsencrypt/live/example.com/fullchain.pem
    tlsKeyPath: /etc/letsencrypt/live/example.com/privkey.pem

启用 TLS 后访问 https://:/;登录 cookie 自动带 Secure,网关自身响应 (登录页 / 重定向 / 拒绝)带 HSTS。自签名证书首次访问会看到浏览器警告,属预期行为。

默认 lanCidrs10.0.0.0/8172.16.0.0/12192.168.0.0/16169.254.0.0/16, IPv6 的 fe80::/10(link-local)与回环地址始终免密。