Repository navigation
fix(config): avoid empty direct detours for DNS transports - #146
LiuLin1220 wants to merge 2 commits into
Conversation
kokhlo
left a comment
There was a problem hiding this comment.
Verified against current main (dbf3ffb, go 1.25.6 as CI pins it).
The production fix is already on main by another route. 8209feb (2026-10-02, "Refactor DNS and Hiddify options handling") added dialDetour() at v2/config/builder.go:99, which maps OutboundDirectTag/OutboundDirectFragmentTag to "" and is applied at every detour site (dns.go:420, builder.go:112 NTP, chain.go:76, warp.go:210). The per-call-site "" this PR passes in dns.go is superseded — and those call sites were rewritten again by the DNS-group work (06eaf61, 40986a1), so the dns.go hunks will not rebase cleanly.
The test file is the part that still matters. Nothing else in v2/config/*_test.go starts a real box, and main has no coverage of dialDetour at all. I dropped v2/config/dns_startup_test.go onto pristine main:
$ go test ./v2/config/ -run "TestBuildConfigStartsWithDirectDNSTransports|TestRawDNSDetourToEmptyDirectOutboundIsRejected" -count=1
ok github.com/hiddify/hiddify-core/v2/config 0.444s
then mutated dialDetour to the identity (return tag) to confirm the test actually bites:
--- FAIL: TestBuildConfigStartsWithDirectDNSTransports (0.03s)
dns_startup_test.go:44: start generated config: start dns/udp[dns-remote-no-warp]: detour to an empty direct outbound makes no sense
dns_startup_test.go:44: start generated config: start dns/https[dns-direct]: detour to an empty direct outbound makes no sense
Exactly the startup failure this PR was opened for. So the suggestion: rebase keeping only v2/config/dns_startup_test.go and drop the dns.go hunks — the PR becomes the regression test for the central fix, with no behavior change to argue about.
Summary
direct-fragment §hide§available as a terminal route outboundBuildConfig -> box.New -> box.Start -> Closeregression testRoot cause
The generated
dns-remote-no-warp, HTTPSdns-direct, anddns-trick-directtransports setDialerOptions.Detourto the fragment direct outbound. That outbound is valid as a terminal route action, but sing-box rejects it when it is initialized as an empty direct dialer detour:The first commit reproduces the failure across bare, explicit UDP, and HTTPS direct DNS addresses, with DNS fragmentation both disabled and enabled.
Change
Clear those DNS detours so the transports use their own direct dialer. The change preserves:
This PR does not change regional routing, user-rule behavior, Google routing policy, WARP endpoint topology, or sing-box validation.
Verification
Passed:
Red/green evidence:
Broader baseline comparison:
go test -count=1 ./v2/...still reaches the pre-existingv2/profile/test.TestAddByContentfailure because this build lackswith_wireguard; the same failure reproduces ondb74dfcgo vet ./v2/configstill reports the pre-existingv2/config/warp.go:212:4: unreachable code; the same diagnostic reproduces ondb74dfcNo workflow, Makefile, submodule, or release-build files are changed.