fix(platform): 隧道不再强制单协议族,改用 happy-eyeballs 自动选路#394
Merged
Conversation
之前 tunnel-client 会把 binding 里的 ipFamily 透传给所有 WebSocket 构造器(family: 4|6),强制只用 IPv4 或 IPv6。当某条协议族路由 有 ECMP 黑洞时(实测 ~35% 丢包率),每次 restart 冷启动都有概率 连不上平台,导致 dashboard 显示「未授权」、平台侧机器离线。 修复: - tunnel-client.ts: 控制连接和数据流都不传 family,让 Node 内置 happy-eyeballs (autoSelectFamily) 同时拨 IPv4+IPv6,谁先到用谁 - 移除 setPlatformIpFamily 运行时落盘:不再因一次侥幸连接把 ipFamily 写回 platform.json 锁死坏路径 - bind.ts: 仍保留多族兜底尝试(bind HTTP 请求需要实际打通), 但不再把成功的协议族写入绑定文件 - binding.ts: 删除 setPlatformIpFamily(无调用方) 测试:更新 platform-bind-ip-family.test.ts 和 tunnel-client-ip-family.test.ts 验证新行为。
family-flip 逻辑移除后,connectFails 只剩写入(自增/清零)无人读取, 且注释仍称其「驱动 backoff + 协议族翻转」——两者皆已不成立。删除该变量 并更正注释,重连退避由独立的 backoff 变量驱动。
隧道改用 happy-eyeballs 后运行期已不再读取该字段、bind 也不落盘, 旧注释仍称「固定走该协议族」会误导。标注 @deprecated 并说明仅为 兼容旧 platform.json 保留解析。(Codex 二轮 review P3)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
botmux restart 后概率性出现 dashboard 显示「平台未授权」、平台侧机器显示离线。
根因:tunnel-client.ts 会把 platform.json 里的 ipFamily 透传给所有 WebSocket 构造器,强制只用单一协议族。当该协议族路由有 ECMP 黑洞时(实测 ~35% 丢包率),冷启动时控制连接连不上平台。更糟的是,某次侥幸连上后会把 ipFamily 写回绑定文件,锁死在坏路径上。
修复
影响面
测试验证