Skip to content

feat(v3): broker 本机管理面板 + Tailscale 跨网连接检测#201

Open
raysonmeng wants to merge 2 commits into
feat/v3-securityfrom
feat/v3-web-dashboard
Open

feat(v3): broker 本机管理面板 + Tailscale 跨网连接检测#201
raysonmeng wants to merge 2 commits into
feat/v3-securityfrom
feat/v3-web-dashboard

Conversation

@raysonmeng

Copy link
Copy Markdown
Owner

摘要 / Summary

abg broker start 现在附带本机 web 管理面板 + Tailscale 跨网连接检测,让「看房间/建房 + 邀请协作者跨网接入」开箱即用。

⚠️ 请勿合并 / DO NOT MERGE —— 先试用稳定期。base = feat/v3-security(stacked,diff 仅本 feature 一个 commit)。

变更 / Changes(commit ffc60dd

  • src/broker-web.ts127.0.0.1:4701 独立 Bun.serve(与对外 WS broker 4700 分开)。GET / 中文仪表盘(看所有房间/成员/白板)、GET /api/statePOST /api/rooms(建房,复用 §11.2 闭门授权)。强制 loopback 绑定 + Host 头白名单防 DNS-rebinding —— 绝不做无鉴权对外管理台。
  • src/net-detect.tsabg broker start 启动「网络可达性 / 邀请协作者」连接卡——检测 Tailscale(100.x)/局域网,拼出协作者该跑的 export AGENTBRIDGE_BROKER_URL + abg join + 没装 Tailscale 的邀请指引(检测+给命令;不自动安装、不做公网回退)。probeBroker 供 join 侧探测。
  • src/cli/broker.ts--web-port/--no-web/--no-open;非 SSH 自动开浏览器、SSH 提示端口转发;web/检测全 fail-inert。修真 bug:信号处理器移到慢速 Tailscale 探测之前注册(Ctrl-C during detect 不再被默认 kill)。
  • slugify 上移到 room-service(域层,修服务→CLI 反向依赖);cli/broker.ts resolveDbPath 收敛到 collab-store。

测试 / Test plan

  • bun run check 全绿(1844 pass)
  • broker-web.test(Host 守卫 + 401/400/409/幂等 + loopback 强制)、net-detect.test(4 分支连接卡 + probe)、broker-graceful-shutdown(--no-web)
  • Cross-review:6 轮 review,连续两轮 0 真实 issue 收敛

安全立场

管理台只绑 127.0.0.1。远程访问用 SSH 端口转发或 tailscale serve(自带 tailnet 身份),永不裸 0.0.0.0。

🤖 Generated with Claude Code

abg broker start 现在:
- 启动一个仅本机(127.0.0.1:4701)的 web 管理面板:看所有房间/成员/白板 + 在网页建房
  (loopback-only 强制 + Host 白名单防 DNS-rebinding;POST /api/rooms 复用 §11.2 闭门授权:
  未登录401/纯标点400/已存在非成员409不自授/成员幂等;非 SSH 自动开浏览器、SSH 改提示端口转发;
  --web-port/--no-web/--no-open)
- 打印「网络可达性 / 邀请协作者」连接卡:检测 Tailscale(100.x)/局域网,拼出对方该跑的
  export AGENTBRIDGE_BROKER_URL + abg join 命令 + 没装 Tailscale 的指引
  (用户拍板:检测+给命令,不自动安装、不做公网回退)
- 修真 bug:信号处理器移到慢速 Tailscale 探测之前注册(Ctrl-C during detect 不再被默认 kill);
  连接卡 + web 启动全 fail-inert(失败只打日志,绝不掀 broker)
- slugify 上移到 room-service(域层,修服务层→CLI 层反向依赖);cli/broker.ts resolveDbPath 收敛到 collab-store

新模块 src/broker-web.ts(管理面板)+ src/net-detect.ts(检测+连接卡+join 探测)。
测试:broker-web(10)+ net-detect(7)+ graceful-shutdown(--no-web)。bun run check 全绿。
Cross-review:6 轮 review,连续两轮 0 真实 issue 收敛。

feat: broker local admin dashboard + Tailscale cross-network connectivity detection

`abg broker start` now serves a loopback-only (127.0.0.1:4701) web dashboard (view rooms /
members / whiteboards + create a room; loopback-enforced + Host-header DNS-rebinding guard;
POST reuses the §11.2 closed-by-default authz; SSH-aware auto-open) and prints a connectivity
card (detect Tailscale 100.x / LAN, then hand peers the exact connect command + invite guidance;
detect-and-guide — no auto-install, no public fallback). Also fixes a shutdown race (signal
handlers now registered before the slow detection probe) and moves slugify to the domain layer.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012rhWKm1VUSnEVxmjpYwNfc
- 仪表盘每个房间卡新增可复制的 `abg join <roomId>` 命令(user-select:all),房间 id 一眼可见可贴
- POST /api/rooms 建新房后向 broker 终端打印 `已创建房间 <id>(<name>)by <by> — 加入:abg join <id>`
- safeForLog() 剥除 name 的控制+格式字符(\p{Cc}\p{Cf},CWE-117 防终端注入)——name 是 POST body
  攻击者可控、web 面 loopback-only 但文档鼓励 SSH/tailscale 转发;roomId 已 slug-safe、createdBy 是认证身份
- 测试:建房日志断言 + 防注入断言(ESC/CRLF name → 日志剥净)+ 把原本空过的 join-render 测试
  改成断言 render 源码逐房从 r.roomId 构造命令(删 join div/硬编码均会失败,有区分力)

cross-review:2 轮各 2 个独立 reviewer,第 1 轮抓出终端注入(MEDIUM)+空过测试,修复后第 2 轮双 0 收敛。

feat(broker-web): per-room `abg join <id>` on cards + create-room log (room name sanitized vs terminal injection)

Dashboard cards now show a copy-pasteable join command; creating a room logs the id + join line to the
broker terminal. The attacker-controllable room name is stripped of control/format chars before logging
(CWE-117) — the web face is loopback-only but the docs invite SSH / tailscale forwarding.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012rhWKm1VUSnEVxmjpYwNfc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant