@ds-hu/dsh-tailcat-remote 0.0.0-stage → 0.1.0

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.
@@ -0,0 +1,38 @@
1
+ # The @ds-hu/dsh-tailcat-remote bundle patch.
2
+ #
3
+ # One row: the Host half. `name` must be this package's name so the Loader
4
+ # resolves the row (and therefore the code it mounts) from the profile's
5
+ # node_modules. The browser half is declared by package.json's `dsh.client`
6
+ # and served by the Web shell; it lives in the same page tree as the other
7
+ # sidebar pages.
8
+ #
9
+ # The plugin owns its runtime data in $DSH_HOME/tailcat-remote/ (the device
10
+ # allow-list) and the tailcat private key under the platform user-config
11
+ # directory. It publishes no Cordis service, so the row sits loose in the
12
+ # Host root realm instead of an `isolate` group.
13
+ #
14
+ # Every field below is optional. Defaults are chosen for the common case
15
+ # (Unix-socket door, saved stable key, allow-list off). Uncomment a field only
16
+ # when the machine needs a different placement.
17
+ #
18
+ # - insert:
19
+ # - id: dsh-tailcat-remote
20
+ # name: '@ds-hu/dsh-tailcat-remote'
21
+ # config:
22
+ # binaryPath: tailcat # PATH name or absolute path
23
+ # port: 13080 # virtual port inside tailcat
24
+ # listen: socket # socket | tcp
25
+ # socketPath: '' # empty = $DSH_HOME/tailcat-remote.sock
26
+ # keyName: dsh-tailcat # saved tailcat key name (or path)
27
+ # addressMode: stable # stable | ephemeral
28
+ # derpMapUrl: '' # empty = tailcat default
29
+ # autoStart: true
30
+ # logAccess: true
31
+ # restartEnabled: true
32
+ # maxRestartAttempts: 10
33
+ # restartBaseDelayMs: 500
34
+ # restartMaxDelayMs: 30000
35
+
36
+ - insert:
37
+ - id: dsh-tailcat-remote
38
+ name: '@ds-hu/dsh-tailcat-remote'
@@ -0,0 +1,142 @@
1
+ # Host ↔ 面板契约
2
+
3
+ 面板只依赖一个 JSON 路由。它是 owner-only 的 DSH Fetch 路由;非 owner 在到达这里之前就被 DSH 的 Connection 层拒绝,所以插件不重复做身份判断。
4
+
5
+ - 路径:`/api/tailcat-remote`(精确匹配)
6
+ - 方法:`GET`、`POST`
7
+ - 请求体:`POST` 为 JSON,最大 64 KiB
8
+ - 响应:`application/json; charset=utf-8`,`cache-control: no-store`
9
+ - 失败:HTTP 4xx/5xx + `{ "ok": false, "error": { "code", "message" } }`
10
+
11
+ ## GET
12
+
13
+ 读取一份完整快照,不改状态。
14
+
15
+ ```json
16
+ {
17
+ "ok": true,
18
+ "plugin": { "name": "@ds-hu/dsh-tailcat-remote", "version": "0.1.0" },
19
+ "now": "2026-11-24T16:22:50.998Z",
20
+ "web": { "protocol": "http:", "port": 3080 },
21
+ "config": {
22
+ "binaryPath": "tailcat",
23
+ "port": 13080,
24
+ "listen": "socket",
25
+ "keyName": "dsh-tailcat",
26
+ "addressMode": "stable",
27
+ "autoStart": true,
28
+ "logAccess": true,
29
+ "restartEnabled": true,
30
+ "maxRestartAttempts": 10,
31
+ "restartBaseDelayMs": 500,
32
+ "restartMaxDelayMs": 30000,
33
+ "customDerpMap": false
34
+ },
35
+ "door": {
36
+ "phase": "listening",
37
+ "listening": true,
38
+ "mode": "socket",
39
+ "socketPath": "/home/you/.dsh/tailcat-remote.sock",
40
+ "port": null,
41
+ "target": { "host": "127.0.0.1", "port": 3080 },
42
+ "lastError": null
43
+ },
44
+ "tailcat": {
45
+ "phase": "online",
46
+ "desired": true,
47
+ "address": "tc…",
48
+ "keyMode": "saved",
49
+ "keyName": "dsh-tailcat",
50
+ "addressMode": "stable",
51
+ "port": 13080,
52
+ "listen": "socket",
53
+ "endpoint": { "mode": "socket", "socketPath": "/home/you/.dsh/tailcat-remote.sock" },
54
+ "region": { "id": 304, "name": "Tokyo" },
55
+ "binary": { "requested": "tailcat", "resolved": "/usr/local/bin/tailcat", "version": "v0.8.0", "error": null },
56
+ "restarts": 0,
57
+ "lastError": null,
58
+ "lastExit": null,
59
+ "warnings": [],
60
+ "stderrTail": ["# Selected bootstrap relay region 304, Tokyo"],
61
+ "recent": [
62
+ {
63
+ "kind": "connection",
64
+ "peer": "nodekey:12815ee7…0d48",
65
+ "protocol": "tcp",
66
+ "port": 13080,
67
+ "service": "forward",
68
+ "via": "direct:192.168.1.3:51352",
69
+ "durationMs": 8104,
70
+ "at": "2026-11-24T16:27:43.000Z"
71
+ }
72
+ ],
73
+ "refusals": 0,
74
+ "startedAt": "2026-11-24T16:22:00.000Z",
75
+ "onlineAt": "2026-11-24T16:22:02.000Z",
76
+ "nextRestartAt": null
77
+ },
78
+ "devices": {
79
+ "allow": [],
80
+ "enforced": false,
81
+ "count": 0,
82
+ "file": "/home/you/.dsh/tailcat-remote/devices.json",
83
+ "updatedAt": null,
84
+ "warnings": []
85
+ },
86
+ "pairing": {
87
+ "address": "tc…",
88
+ "port": 13080,
89
+ "localPort": 18080,
90
+ "command": "tailcat forward tc… 18080:13080",
91
+ "qr": { "version": 8, "size": 49, "rows": ["111111100…"] }
92
+ },
93
+ "safety": { "allowListEnforced": false, "rotateRevokesBrowserSessions": false }
94
+ }
95
+ ```
96
+
97
+ `pairing` 在地址尚未产生时为 `null`。`tailcat.address` 与 `pairing.address` 相同;后者附带命令与二维码矩阵。`stderrTail` 已脱敏并截断,仅用于诊断。
98
+
99
+ `tailcat.phase` 的取值:`stopped`、`starting`、`online`、`stopping`、`restarting`、`error`。
100
+
101
+ ## POST
102
+
103
+ 请求体必须包含 `action`。动作串行执行;`start` 会先确保 door 可用。
104
+
105
+ | action | 额外字段 | 行为 | 成功后的额外状态 |
106
+ | --- | --- | --- | --- |
107
+ | `start` | — | 启动 tailcat;已停止时重建进程 | `tailcat.desired: true` |
108
+ | `stop` | — | 停止 tailcat,保留 door | `tailcat.phase: "stopped"`,地址清空 |
109
+ | `restart` | — | 停掉再用当前配置启动;地址通常不变 | 新进程、`restarts` 递增 |
110
+ | `rotate` | — | 覆盖保存密钥、重启、等新地址上线 | `tailcat.address` 改变,旧地址失效 |
111
+ | `devices` | `allow: string[]` | 规范化并持久化白名单;运行中的 tailcat 会重启以应用 | `devices.enforced` / `count` 更新 |
112
+
113
+ 示例:
114
+
115
+ ```json
116
+ { "action": "devices", "allow": ["nodekey:…64 hex…"] }
117
+ ```
118
+
119
+ `allow: []` 表示仅凭地址访问;非空数组会变成 `tailcat serve --allow=…`。
120
+
121
+ 成功响应是 `{ "ok": true, ...snapshot }`,与 GET 同形,面板直接用它替换本地状态。
122
+
123
+ ### 错误码
124
+
125
+ | HTTP | code | 场景 |
126
+ | --- | --- | --- |
127
+ | 400 | `invalid-json` | 请求体不是 JSON |
128
+ | 400 | `unknown-action` | 未知 action |
129
+ | 400 | `invalid-device-key` / `invalid-device-list` | 公钥格式不对或 `allow` 不是数组 |
130
+ | 409 | `door-in-use` / `door-path-occupied` | door socket 被另一个活进程占用,或路径不是 socket |
131
+ | 409 | `door-tls-unsupported` | Web listener 是 HTTPS |
132
+ | 413 | `body-too-large` | 请求体超过 64 KiB |
133
+ | 500 | `internal` | 未预期错误 |
134
+ | 503 | `tailcat-not-found` / `tailcat-spawn-failed` | tailcat 找不到或无法启动 |
135
+ | 503 | `door-listen-failed` / `door-socket-missing` | door 未监听或 socket 丢失 |
136
+ | 503 | `disposed` | 插件正在卸载 |
137
+
138
+ `tailcat-not-found` 的 message 会包含 `binaryPath` 与底层解析错误;面板用 `tailcat.binary.resolved === null && tailcat.phase === "error"` 识别安装提示。
139
+
140
+ ## 兼容性
141
+
142
+ 这是插件内部契约,不承诺跨大版本稳定。客户端与 Host 在同一个包里发布,版本一致;升级时一起升级。白名单文件格式是持久化契约(`version: 1`),需要向后兼容。
@@ -0,0 +1,84 @@
1
+ # 安全说明
2
+
3
+ 远程访问把一个本来只对本机开放的 Web GUI 交给 tailcat 隧道。它没有改变 DSH 的登录模型,但确实扩大了可达范围。这份文档说明信任边界、已知限制和推荐配置。
4
+
5
+ ## 信任边界
6
+
7
+ ```
8
+ 不可信网络
9
+ │ 只知道 tailcat 地址,或地址 + 未授权设备密钥
10
+ ▼
11
+ tailcat DERP / 直连(加密)
12
+ │
13
+ ▼
14
+ tailcat serve(本机进程)
15
+ │ 13080 → Unix socket 0600
16
+ ▼
17
+ Door ──► DSH Connection(cookie、Host、Origin、owner)
18
+ │
19
+ ▼
20
+ DSH Web / API / WebSocket
21
+ ```
22
+
23
+ - **Door 不是公网监听。** 默认只创建 `$DSH_HOME/tailcat-remote.sock`(0600),本机其他用户不能连接;同用户的本地进程可以连接,这是本机进程信任模型的自然结果。
24
+ - **tailcat 是唯一的入口。** 插件不打开 TCP 端口。只有 `tailcat serve` 能把虚拟端口 13080 映射到 door。
25
+ - **鉴权仍由 DSH 负责。** Door 不做自己的账号体系,也不把 remote 标成 owner;它让 DSH 对远程请求执行同一套 `requestRejection` / cookie 判断。
26
+ - **地址是一份凭据。** tailcat 地址本身足以建立隧道;没有设备白名单时,拿到地址就能到达 DSH 登录入口,再由 DSH 的 cookie 机制决定会话。地址应当按密码对待。
27
+
28
+ ## 首次访问如何变成登录
29
+
30
+ 远程浏览器第一次打开 `http://127.0.0.1:18080/` 时没有 DSH cookie。Door 只在这个精确时刻调用 DSH 的 `authorizeIndex`,后者用 Host 进程持有的一次性 token 签发一个绑定 `127.0.0.1:18080` 的 HttpOnly cookie,并回 303 到 `./`。token 不出现在远程 URL 里。
31
+
32
+ 副作用是:**能在 tailcat 上到达 door 的客户端,会自动获得一个 DSH 浏览器会话**。这正是“有地址就能访问、不用输入 token”的设计目标,也意味着地址泄露等于会话泄露。设备白名单是限制这一点的机制。
33
+
34
+ ## 设备白名单
35
+
36
+ 默认关闭,面板会显示红色警告。添加至少一个客户端公钥后,tailcat 以 `--allow=…` 启动,不在列表中的客户端在握手阶段被拒绝,door 根本收不到请求。
37
+
38
+ 在客户端生成身份:
39
+
40
+ ```sh
41
+ tailcat genkey --client --key=client-default
42
+ ```
43
+
44
+ 命令会打印一行 `nodekey:…` 公钥;把它粘进面板的“允许的客户端公钥”,保存并应用。私钥留在客户端,不要发到 Host。
45
+
46
+ 白名单保存在 `$DSH_HOME/tailcat-remote/devices.json`,0600,原子替换。损坏时插件回退到“仅地址”模式并在面板给出警告;这是一次可用性优先的降级,发现警告后应立即修复。
47
+
48
+ ## 地址轮换
49
+
50
+ “更换地址”会覆盖保存的 tailcat 服务器密钥、重启隧道,使旧地址立即失效。它**不会**撤销已经签发的 DSH 浏览器 cookie:DSH 没有对外的“撤销这个 cookie”接口,插件也不伪造一个。旧浏览器会一直持有会话,直到 cookie 到期或对应的浏览器会话记录被清除。
51
+
52
+ 如果地址已经泄露,正确顺序是:
53
+
54
+ 1. 在面板更换地址;
55
+ 2. 在 DSH 的会话/凭据管理里撤销旧会话(如果当前版本提供该入口);
56
+ 3. 检查白名单,必要时先加白名单再分享新地址。
57
+
58
+ 只做第 1 步不足以让已拿到 cookie 的攻击者下线。
59
+
60
+ ## 已知限制
61
+
62
+ - **Door 只支持明文 HTTP 的 Web listener。** 如果 DSH 配置了 TLS,插件拒绝启动 door(`door-tls-unsupported`)。原因是没有可重放的 `Set-Cookie` 语义:远程客户端看到的是 `http://127.0.0.1:18080`,把 `Secure` cookie 直接搬过去会失效。要在 TLS 场景使用,应让 tailcat 映射到一个明确终止 TLS 的反向代理,并单独评估 cookie 属性;当前版本不提供这个模式。
63
+ - **`listen: tcp` 会扩大本机可达面。** 绑定 `127.0.0.1` 后,本机任何进程都能访问 door;Unix socket 0600 是默认值。除非 Unix socket 不可用,不要改成 tcp。
64
+ - **tailcat 自身的信任假设。** 插件信任 tailcat 二进制、它的 DERP map、本机代理配置和本机用户环境。请从可信来源安装 tailcat,并保持更新。
65
+ - **访问日志是诊断数据。** `--log` 会记录 peer 公钥前缀/后缀、端口、路径和时长;插件对地址和完整 nodekey 做脱敏,但日志仍可能透露连接时间与设备数量。关闭 `logAccess` 可减少记录。
66
+ - **二维码等同地址。** 二维码只编码 tailcat 地址;截图、投屏或转发二维码与转发地址等价。
67
+ - **本插件没有经过独立安全审计。** 它复用 DSH 的认证路径,但没有形式化验证。
68
+
69
+ ## 推荐配置
70
+
71
+ 1. 保持默认的 Unix socket door,不要直接暴露 3080。
72
+ 2. 在分享地址前添加至少一个设备公钥;面板的红色警告消失后再继续。
73
+ 3. 用 `stable` 地址模式;需要轮换时用面板按钮,不要手改密钥文件。
74
+ 4. 不要把地址、二维码或带 `nodekey:` 的日志贴到公开 issue;需要贴日志时先脱敏。
75
+ 5. 只从官方发行版或可信包管理器安装 tailcat。
76
+ 6. 在不再需要远程访问时,在面板停止隧道,或停用插件。
77
+
78
+ ## 报告问题
79
+
80
+ 发现安全问题请通过 GitHub Security Advisory 私下报告:
81
+
82
+ <https://github.com/ds-hu/dsh-tailcat-remote/security/advisories/new>
83
+
84
+ 不要在公开 issue 中附带真实地址、私钥或 cookie。
@@ -0,0 +1,136 @@
1
+ # 技术说明
2
+
3
+ 这份文档面向维护者,解释远程访问为什么这样拆、请求如何穿过 door、状态放在哪里、失败时会发生什么。用户向的用法见 [README](../README.md),安全边界见 [SECURITY](./SECURITY.md),面板与 Host 的 JSON 契约见 [CONTRACT](./CONTRACT.md)。
4
+
5
+ ## 目标与边界
6
+
7
+ 需求只有三件事:
8
+
9
+ 1. 让本机 Harness 的 Web GUI 可以从另一个网络访问;
10
+ 2. 不开放公网端口,不改动入站防火墙;
11
+ 3. 用 tailcat 当唯一的传输层,浏览器最终访问的是客户端自己的 `127.0.0.1`。
12
+
13
+ 插件只做服务端:一个 Host 插件、一个侧边栏页面、一个配对页。客户端仍然使用 tailcat 自己的 `forward` 命令,本插件不包含客户端程序。
14
+
15
+ ## 为什么是这三个部件
16
+
17
+ ```
18
+ Host 插件
19
+ ├── Door Unix socket 上的本地 HTTP 门卫
20
+ ├── TailcatSupervisor tailcat serve 进程的生命周期
21
+ └── RemoteAccess 把两者与设备列表、配置、状态组合起来
22
+ ```
23
+
24
+ - **Door** 是唯一能被 tailcat 访问的本地端点。默认是 `$DSH_HOME/tailcat-remote.sock`,权限 0600;`tailcat serve` 把虚拟端口 13080 映射到它。它不做自己的鉴权,而是把请求交给 DSH 的 `connection` 服务判断。这样远程访问与本地访问共用同一套 cookie、Host/Origin 校验和 owner 语义。
25
+ - **TailcatSupervisor** 只负责一个子进程:确保可执行文件与保存密钥存在,拼出 argv,解析 stdout 地址与 stderr 访问日志,做崩溃重启和地址轮换。
26
+ - **RemoteAccess** 是门面。它串行化所有变更操作,向面板提供一份快照,避免“页面连续点两次启动”这类竞态。
27
+
28
+ 没有把 13080 直接开在 TCP 上。TCP `127.0.0.1` 仍对同机所有进程可见,Unix socket 的 0600 权限更小;tailcat 能在同机直接连 socket,不需要 TCP。配置保留 `listen: tcp` 只是为了诊断或在不支持 Unix socket 的环境里逃生。
29
+
30
+ ## 一次远程请求的路径
31
+
32
+ ```mermaid
33
+ sequenceDiagram
34
+ autonumber
35
+ participant B as 客户端浏览器
36
+ participant F as tailcat forward
37
+ participant T as tailcat serve(本机)
38
+ participant D as Door(Unix socket)
39
+ participant C as DSH Connection
40
+ participant W as DSH Web / API
41
+
42
+ B->>F: GET http://127.0.0.1:18080/
43
+ F->>T: tailcat 隧道(DERP 或直连)
44
+ T->>D: 13080 -> $DSH_HOME/tailcat-remote.sock
45
+ D->>C: requestRejection(head)
46
+ C-->>D: undefined(没有 cookie,需要认领)
47
+ D->>C: authorizeIndex(req, res)
48
+ C-->>D: 303 + Set-Cookie(authority=127.0.0.1:18080)
49
+ D-->>B: 303 Location: ./ + Set-Cookie
50
+ B->>D: GET /(携带 cookie)
51
+ D->>W: 原样转发,保留 Host
52
+ W-->>B: HTML / JS / WebSocket 升级
53
+ ```
54
+
55
+ 关键点:
56
+
57
+ - **只在 `GET /` 且没有 `?token=` 时尝试认领**。这是 DSH 原本的登录入口;其它路径直接原样转发。`?token=` 必须继续走 DSH 本身,避免插件截获一次性 token。
58
+ - **cookie 的 authority 是客户端看到的 `127.0.0.1:18080`**,不是 Host 进程的 `127.0.0.1:3080`。DSH 的 cookie 名由 authority 派生;door 必须让 DSH 在“远程视角”下发 cookie,因此它能重放 `authorizeIndex` 的 303 和 `Set-Cookie`,而不是自己造 cookie。
59
+ - **原始字节转发**:door 解析完 HTTP 头后,把已读字节与后续字节一起 `pipe` 到上游,Host 头保持客户端视角。WebSocket 的 `Upgrade` 也是同一条路。不经过 Node 的 HTTP server,避免 `Host` 被重写、`Upgrade` 被吞掉。
60
+ - **不把 token 放进浏览器地址**。token 只在 Host 内部用于认领;远程浏览器看到的是 303 到 `./` 和 HttpOnly cookie。
61
+
62
+ ## 生命周期
63
+
64
+ 1. Host 插件激活,`RemoteAccess.start()` 先启动 door,再按 `autoStart` 启动 tailcat。
65
+ 2. Door 监听 Unix socket。若 socket 文件已存在且可连接,说明另一个实例还在用,door 报错;若是上次崩溃留下的死文件,door 在确认不可连接后删除并重建。
66
+ 3. 可执行文件解析:`subprocess.resolveExecutable(binaryPath, env)`;失败会进入 `error` 状态,并在面板显示安装提示。
67
+ 4. 保存密钥:`stable` 模式检查 `<user config>/tailcat/keys/<keyName>.private.json`,不存在就运行一次 `tailcat genkey --fixed-region`。`ephemeral` 模式传 `--key=new`,每次启动换地址。
68
+ 5. 启动:`tailcat --json --key=… serve --log [--allow=…] 13080:<socket>`。
69
+ 6. 上线:stdout 的 `{"listenAddr":"tc…"}` 或 stderr 的 `Server listening …` 任一线索都会把状态置为 `online`;面板开始显示地址、二维码和 forwarded 命令。
70
+ 7. 退出:意外退出且 `restartEnabled` 时按指数退避重启,连续失败达到 `maxRestartAttempts` 后停在 `error`;主动停止不重启。
71
+ 8. 停用插件时先停 tailcat,再关 door 并删除 socket 文件。
72
+
73
+ `RemoteAccess` 用一个 promise 队列串行化 `start/stop/restart/rotate/saveDevices`,所以页面的重复点击不会产生两个 tailcat 进程。读取快照不走队列。
74
+
75
+ ## 状态与文件
76
+
77
+ | 位置 | 内容 | 谁写 |
78
+ | --- | --- | --- |
79
+ | `$DSH_HOME/tailcat-remote.sock` | door 的 Unix socket,模式 0600 | Door |
80
+ | `$DSH_HOME/tailcat-remote/devices.json` | 设备公钥白名单,模式 0600,原子替换 | RemoteAccess |
81
+ | `<user config>/tailcat/keys/<keyName>.private.json` | tailcat 保存的服务器密钥 | tailcat 自己 |
82
+ | `<user config>/tailcat/keys/<client>.private.json` | 客户端身份密钥(在客户端机器) | tailcat 自己 |
83
+
84
+ 白名单是运行时状态,不是 Config。这样页面保存设备时不必改 profile patch,也不会触发插件重载;代价是它需要自己负责文件权限与损坏恢复。
85
+
86
+ ## 配置项
87
+
88
+ 所有字段都有默认值,通常不需要改。需要改时在 bundle row 的 `config` 里写。
89
+
90
+ | 字段 | 默认 | 说明 |
91
+ | --- | --- | --- |
92
+ | `binaryPath` | `tailcat` | PATH 名或绝对路径。找不到时面板给出安装提示。 |
93
+ | `port` | `13080` | tailcat 隧道内的虚拟端口,不是本机监听端口。 |
94
+ | `listen` | `socket` | `socket` 使用 0600 Unix socket;`tcp` 绑定 `127.0.0.1:<port>`。 |
95
+ | `socketPath` | 空 | 空表示 `$DSH_HOME/tailcat-remote.sock`。 |
96
+ | `keyName` | `dsh-tailcat` | 保存密钥名;带 `/` 时按路径处理。 |
97
+ | `addressMode` | `stable` | `stable` 重启不变;`ephemeral` 每次启动换地址。 |
98
+ | `derpMapUrl` | 空 | 自定义 DERP map;默认用 tailcat 的。 |
99
+ | `autoStart` | `true` | Host 激活时是否自动起隧道。 |
100
+ | `logAccess` | `true` | 传 `--log`,面板显示最近连接与拒绝。 |
101
+ | `restartEnabled` | `true` | 意外退出后是否自动重启。 |
102
+ | `maxRestartAttempts` | `10` | 连续重启上限。 |
103
+ | `restartBaseDelayMs` | `500` | 首次退避;之后翻倍。 |
104
+ | `restartMaxDelayMs` | `30000` | 单次退避上限。 |
105
+
106
+ `addressMode: ephemeral` 与 `autoStart` 同时开启时,每次 Host 重启地址都会变化;想用二维码长期配对就用 `stable`,需要换地址时在面板点“更换地址”。
107
+
108
+ ## 面板
109
+
110
+ 侧边栏入口是一个 `sidebar.panellist` row,id 与 `main` 的 key 都是 `tailcat-remote`。页面注册在 `main`,使用 `locale: 'tailcat-remote'` 获得注入的 `t`。
111
+
112
+ 页面只做显示与动作,不持有业务状态:
113
+
114
+ - 每 2.5 秒 `GET /api/tailcat-remote`,页面隐藏时暂停;
115
+ - 动作 `POST` 同一路径,成功后用响应里的快照立即刷新;
116
+ - 二维码由 Host 生成矩阵,客户端只把矩阵转成一条 SVG path,避免把 56KB 的 QR 生成器再打包进客户端;
117
+ - 地址/命令/本地 URL 都有复制按钮,复制失败时回退到隐藏 textarea + `execCommand`;
118
+ - “更换地址”是两步确认,并明确提示:旧地址立即失效,但已签发的 DSH 浏览器 cookie 不会因此撤销。
119
+
120
+ ## 失败模式
121
+
122
+ | 现象 | 原因 | 插件行为 |
123
+ | --- | --- | --- |
124
+ | `tailcat-not-found` | PATH/配置里没有 tailcat | 状态 `error`,面板显示安装提示;door 仍可用 |
125
+ | `door-socket-missing` | door 未起或 socket 被删 | supervisor 拒绝启动,提示先恢复 door |
126
+ | `door-tls-unsupported` | Web listener 是 HTTPS | door 拒绝启动,要求在前面终止 TLS 或改用 HTTP 本地监听 |
127
+ | `EADDRINUSE`/socket 被占用 | 另一个 DSH 实例或残留进程 | door 报错;不会杀掉不认识的进程 |
128
+ | 地址一直不出现 | DERP 不可达、代理阻断 | 状态停在 `starting`;保留 stderr 尾部供诊断 |
129
+ | `[peer] refused … not-in-allow` | 客户端不在白名单 | 面板计数并显示拒绝记录 |
130
+ | 地址更换后页面断开 | 页面本身正走旧隧道 | 属预期;在本机页面操作,或重新配对 |
131
+
132
+ ## 测试
133
+
134
+ `node --test test/*.test.mjs` 只覆盖纯逻辑:地址/日志解析、argv 构造、QR 矩阵、白名单持久化、配置默认值与 manifest。网络行为(真实 tailcat、cookie 认领、WebSocket)靠人工在安装了 tailcat 的环境里验证,避免把外部网络依赖塞进 CI。
135
+
136
+ CI 只做 `npm ci`、语法检查、单元测试、`npm pack --dry-run`。没有构建步骤:包直接发布源码,客户端文件是原生 `React.createElement`,不需要打包。
Binary file
Binary file
package/icon.svg ADDED
@@ -0,0 +1,18 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" role="img" aria-label="Tailcat remote access">
2
+ <defs>
3
+ <linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
4
+ <stop offset="0" stop-color="#071923"/>
5
+ <stop offset="1" stop-color="#0F3341"/>
6
+ </linearGradient>
7
+ <linearGradient id="ink" x1="0" y1="0" x2="0" y2="1">
8
+ <stop offset="0" stop-color="#7DD3FC"/>
9
+ <stop offset="1" stop-color="#2DD4BF"/>
10
+ </linearGradient>
11
+ </defs>
12
+ <rect width="64" height="64" rx="15" fill="url(#bg)"/>
13
+ <path d="M20.5 30.5 18 16.5l12 7" fill="none" stroke="url(#ink)" stroke-width="3.2" stroke-linecap="round" stroke-linejoin="round"/>
14
+ <path d="M43.5 30.5 46 16.5l-12 7" fill="none" stroke="url(#ink)" stroke-width="3.2" stroke-linecap="round" stroke-linejoin="round"/>
15
+ <path d="M17.5 33.5c0-8 6.5-14.5 14.5-14.5s14.5 6.5 14.5 14.5v4.5c0 8-6.5 14.5-14.5 14.5s-14.5-6.5-14.5-14.5z" fill="none" stroke="url(#ink)" stroke-width="3" stroke-linejoin="round"/>
16
+ <circle cx="32" cy="36.5" r="5" fill="url(#ink)"/>
17
+ <path d="M32 41.5v5" stroke="url(#ink)" stroke-width="4.6" stroke-linecap="round"/>
18
+ </svg>
package/index.js ADDED
@@ -0,0 +1,34 @@
1
+ import { Config, resolveConfig } from './src/config.js';
2
+ import { registerControl } from './src/control.js';
3
+ import { errorMessage } from './src/errors.js';
4
+ import { RemoteAccess } from './src/remote.js';
5
+
6
+ /** Loader row identity; must match the id in cordis.patch.yml. */
7
+ export const name = 'dsh-tailcat-remote';
8
+
9
+ /** Host services the plugin requires before it can activate. */
10
+ export const inject = ['connection', 'webServer', 'subprocess'];
11
+
12
+ export { Config };
13
+
14
+ /**
15
+ * Mount the remote-access page and its tailcat runtime.
16
+ * @param {object} ctx - Host plugin context.
17
+ * @param {object} [rawConfig] - validated config from the Loader row.
18
+ */
19
+ export function apply(ctx, rawConfig) {
20
+ const config = resolveConfig(rawConfig);
21
+ const remote = new RemoteAccess(ctx, config);
22
+
23
+ ctx.effect(() => registerControl(ctx, remote), 'tailcat-remote: control route');
24
+ ctx.effect(() => {
25
+ void remote.start().catch((error) => {
26
+ ctx.logger.warn(`tailcat-remote: activation failed: ${errorMessage(error)}`);
27
+ });
28
+ return () => {
29
+ void remote.dispose().catch((error) => {
30
+ ctx.logger.warn(`tailcat-remote: shutdown failed: ${errorMessage(error)}`);
31
+ });
32
+ };
33
+ }, 'tailcat-remote: runtime');
34
+ }
package/locale/de.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Fernzugriff",
4
+ "description": "Erreiche diese Harness von überall über tailcat: Browser per QR-Code koppeln, Geräteschlüssel verwalten und den Tunnel beobachten – ohne öffentlichen Port."
5
+ }
6
+ }
package/locale/en.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Remote Access",
4
+ "description": "Reach this Harness from anywhere over tailcat: pair a browser with a QR code, manage device keys, and watch the tunnel — no public port."
5
+ }
6
+ }
package/locale/es.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Acceso remoto",
4
+ "description": "Accede a este Harness desde cualquier lugar con tailcat: empareja un navegador con un código QR, gestiona las claves de dispositivos y observa el túnel, sin abrir puertos públicos."
5
+ }
6
+ }
package/locale/fr.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Accès distant",
4
+ "description": "Atteignez ce Harness depuis n'importe où avec tailcat : associez un navigateur par QR code, gérez les clés d'appareils et surveillez le tunnel, sans ouvrir de port public."
5
+ }
6
+ }
package/locale/ja.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "リモートアクセス",
4
+ "description": "tailcat 経由でどこからでもこの Harness にアクセス。QR コードでブラウザをペアリングし、デバイスキーとトンネルを管理します。公開ポートは不要です。"
5
+ }
6
+ }
package/locale/pt.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Acesso remoto",
4
+ "description": "Acesse este Harness de qualquer lugar com tailcat: emparelhe um navegador por QR code, gerencie chaves de dispositivos e acompanhe o túnel, sem abrir portas públicas."
5
+ }
6
+ }
package/locale/ru.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Удалённый доступ",
4
+ "description": "Получайте доступ к этой Harness откуда угодно через tailcat: подключайте браузер по QR-коду, управляйте ключами устройств и следите за туннелем без открытых портов."
5
+ }
6
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "远程访问",
4
+ "description": "通过 tailcat 从任意地点访问本 Harness:扫码配对浏览器、管理设备密钥、查看隧道状态,无需开放公网端口。"
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,6 +1,80 @@
1
1
  {
2
2
  "name": "@ds-hu/dsh-tailcat-remote",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Remote access for the DeepSeek Harness Web GUI over tailcat: a pairing page, a tailnet-only door, and a supervised tailcat server — no public port and no inbound firewall change.",
5
+ "type": "module",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "main": "index.js",
10
+ "exports": {
11
+ ".": "./index.js",
12
+ "./client": "./client.js",
13
+ "./locale/*.json": "./locale/*.json",
14
+ "./icon": "./icon.svg",
15
+ "./package.json": "./package.json"
16
+ },
17
+ "engines": {
18
+ "node": ">=20.19.0"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/ds-hu/dsh-tailcat-remote.git"
23
+ },
24
+ "bugs": {
25
+ "url": "https://github.com/ds-hu/dsh-tailcat-remote/issues"
26
+ },
27
+ "homepage": "https://github.com/ds-hu/dsh-tailcat-remote#readme",
28
+ "keywords": [
29
+ "deepseek-harness",
30
+ "dsh",
31
+ "dsh-plugin",
32
+ "dsh-bundle",
33
+ "cordis",
34
+ "tailcat",
35
+ "tailscale",
36
+ "remote-access",
37
+ "wireguard",
38
+ "web-ui"
39
+ ],
40
+ "dsh": {
41
+ "bundle": {
42
+ "patch": [
43
+ "./cordis.patch.yml"
44
+ ]
45
+ },
46
+ "client": {
47
+ "platform": "web",
48
+ "inject": [
49
+ "@deepseek-ai/dsh-client-ui-sidebar",
50
+ "@deepseek-ai/dsh-client-ui-layout",
51
+ "@deepseek-ai/dsh-client-locale"
52
+ ]
53
+ }
54
+ },
55
+ "peerDependencies": {
56
+ "@deepseek-ai/schemastery": "^3.19.0"
57
+ },
58
+ "devDependencies": {
59
+ "@deepseek-ai/schemastery": "^3.19.0"
60
+ },
61
+ "license": "MIT",
62
+ "files": [
63
+ "index.js",
64
+ "src",
65
+ "vendor",
66
+ "client.js",
67
+ "cordis.patch.yml",
68
+ "locale",
69
+ "icon.svg",
70
+ "README.md",
71
+ "README.en.md",
72
+ "docs",
73
+ "LICENSE",
74
+ "NOTICE"
75
+ ],
76
+ "scripts": {
77
+ "test": "node --test test/*.test.mjs",
78
+ "check": "node --check index.js && node --check client.js && node --test test/*.test.mjs"
79
+ }
80
+ }