Leadaxe:LxBox 解析 Xray 配置应复用 registry,不能在 UI 另建解析器
Leadaxe 认为 LxBox 应通过 source-kind registry 和 decode() 处理 Xray 文档,并在保存前运行核心校验;当前 UI 解析会把任意非 sing-box JSON 当成 Xray、丢掉 sibling outbounds,且可能静默保存坏节点。该修复缺少测试与本地化,问题应先按 issue 报告。
作者原文@LeadaxeClosing. This is a bad fix, and please don't open PRs like this — open an issue instead. I've filed the bug here: #209.
The bug is real. The fix isn't.
Why this is the wrong solution
- It ignores the registry. The source-kind registry already knows the Xray dialect:
xray_outbound,xray_config, the outbound array, all withmapper: "xray". Instead of usingdecode()and the registry, you copy-pasted the whole sing-box save path and hardcoded your own heuristics into the screen (protocol, afreedom/blackholelist that already missesdnsandloopback). That's a second parser living in the UI.- It skips the core check. The sing-box branch runs
checkConfigbefore saving (§455). Yours doesn't, and you even added a UI note legitimizing it ("The core doesn't validate it on save"). A broken node now saves silently.- "Not sing-box" ≠ "Xray".
!sourceIsSingboxsends any non-sing-box JSON down the Xray path.- It destroys data. From an Xray document only the first outbound is kept. Nodes that depend on sibling outbounds (
dialerProxy, fragment) break after save.- Sloppy code. The
out['outbounds']branch in_bodyTextXRayis unreachable (it receives the outbound, not the document) and indexesdynamicunchecked. The array form doesn't check the first element isn'tfreedom/blackhole. Re-tagging a bare object writes unindented JSON, everything else is indented. Comments are copied from the sing-box code and describe the wrong thing (type, §435/§575). Not run throughdart format.- New UI string without localization, no spec, no tests, wrong branch (
maininstead ofdevelop).Report bugs as issues with steps to reproduce and a sample config. We'll fix them in a way that fits the architecture.