Leadaxe 介绍 sing-box-lx 连接检查 RPC 的实现

Leadaxe 说明 sing-box-lx 已在 lx 分支完成 SPEC 139 第一期:以真实连接流水线输出 DNS、路由、连接和 HTTP 阶段,并提供 libbox 与命令行接口;目前只在进程内测试,尚未在设备或路由器验证。

作者原文

Release 1 of SPEC 139 (StartConnectionTest) is on lx as of 58791f1e6. It replaces the two calls requested here with one streaming RPC that runs a real request through the core's own pipeline on behalf of a source and reports every stage as a tree:

  • DEPTH_DNS answers the first request: the A/AAAA/HTTPS queries the app would issue, through the DNS rules, with the matched rule, the answering server, rcode and answers per query.
  • DEPTH_ROUTE answers the second: the matched route rule (or final), action, outbound, and the chain unfolded — selector groups, urltest/round_robin/failover picks, detours — without dialing anything.
  • DEPTH_CONNECT and DEPTH_HTTP go further: the node's lookups, detours, TCP/TLS/transport, the target's TLS and HTTP response, with the root cause when the path breaks (it may lie outside the route, e.g. the detour of the DNS server that resolves the node address).

A match on synthetic input (domain/IP only) gives a different answer than a real connection once sniffing, the app, network and port enter the rules, so I kept the match tied to a real connection and made the depth selectable instead.

Commits: a0ec238b8 trace holder common/lxtrace, ca8e4dd11 the RPC, bd8a1f368 libbox CommandClient.StartConnectionTest + sing-box api connection-test <url>, cdf9a297a acceptance stand, 58791f1e6 spec and report. Contract: SPECS/TASKS/139-CONNECTION_TEST/SPEC.md (§3 protocol and libbox shape, §4 stage vocabulary); what landed and what deviates: IMPLEMENTATION_REPORT.md.

libbox shape for Leadaxe/LxBox#176: NewConnectionTestRequest() with setters (SetLink, SetOutboundTag, SetInbound, SetPackageName, SetUID, SetAppDNS, SetDepth, …), client.StartConnectionTest(request, handler) with OnStage / OnResult / OnError, session.Cancel(). The stage and finding vocabularies are open; render an unknown kind as kind + subject + attrs. The protocol is complete now and will not change in release 2 (findings such as dependency_outside_route, fresh at nested DNS levels, the REALITY verdict and WG stages), so the screen can be built against this build.

Verified on the in-process stand under -race (criteria 1, 2 without the finding, 3, 8, 9, 10, 11 of the spec), not yet on a device or a router. I am leaving the issue open until that run.