Skip to content

fix(web-server): reject duplicate remote peers - #1272

Merged
iruriQ merged 1 commit into
mainfrom
fix/issue-1262
Nov 27, 2026
Merged

iruriQ merged 1 commit into
mainfrom
fix/issue-1262

Conversation

@iruriQ

@iruriQ iruriQ commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Fixes #1262

Changes

  • Reject local add and update requests that conflict with a configured Peer by normalized origin or known nodeId, without changing saved peers or retaining temporary clients.
  • Cover same-origin and same-node/different-origin conflicts through the registered RPCs; keep legacy routing coverage with persisted fixtures.

Validation

  • Focused Web Server Node test runner: peer-host-manager.test.ts (18 passed; new regression failed before the fix).
  • npx tsc -b packages/web-server (passed).

No visual changes: backend validation only; the existing UI handles RPC errors.

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Summary

Summary by CodeRabbit

  • 功能改进
    • 添加或更新远程 Peer 时,若其规范化地址或已知节点 ID 与现有记录重复,操作将被拒绝,并保留已保存的配置。
  • 文档
    • 补充重复 Peer 的处理规则及相关错误说明。

Peer 管理器现在会按规范化 origin 和已知 nodeId 检查重复记录。add 和 update 遇到冲突时返回 remote/duplicate-peer,且不保存变更。测试覆盖重复 origin、重复 nodeId 和 Peer 身份匹配。

Changes: Peer 重复检查

Layer / File(s) Summary
Peer 身份读取与重复检查
packages/web-server/src/peer-host-manager.ts, packages/web-server/test/peer-host-manager.test.ts
新增共享逻辑以读取规范化 origin 和有效 nodeId。Peer 匹配及绑定检查使用这些读取逻辑。身份测试改为从存储加载两个指向同一节点的 Peer,并验证 Host 映射及优先级。
add 与 update 的重复拒绝
packages/web-server/src/peer-host-manager.ts, packages/web-server/test/peer-host-manager.test.ts, docs/product/multi-remote-peers.md
add 和 update 保存前检查重复 origin 或 nodeId。冲突时返回 remote/duplicate-peer。测试验证被拒绝后存储记录和 Host 列表不变;文档说明重复 Peer 规则。

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

Suggested reviewers: bytepioneer-ai

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@iruriQ
iruriQ merged commit f76dd64 into main Nov 27, 2026
5 of 8 checks passed
@iruriQ
iruriQ deleted the fix/issue-1262 branch November 27, 2026 01:07
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.

[Bug] 本地 remote-peers/add 未按 origin 或 nodeId 去重,导致同一远端主机重复配对与会话翻倍

2 participants