fix(config): apply ipv4_only IPv6 mode so TUN doesn't hijack the default IPv6 route#140
Open
zZZTeJleTTy3uKZZz wants to merge 1 commit into
Open
Conversation
…ult IPv6 route The ipv6-mode: ipv4_only option was parsed but never applied. setInbound() used isIPv6Supported() - which only resolves the IPv6 loopback and therefore succeeds on virtually any host - instead of the user's IPv6Mode. As a result the TUN always received an IPv6 address and auto_route captured the default IPv6 route, and inbounds bound to ::, regardless of the IPv4-only choice. On hosts without global IPv6 this black-holes every AAAA-first connection (e.g. yandex.ru fails while curl -4 works). Verified by building the patched core and running it under Hiddify 4.1.1: with ipv4_only the TUN is now generated IPv4-only and AAAA sites load correctly. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
zZZTeJleTTy3uKZZz
force-pushed
the
fix/ipv4-only-ipv6-mode
branch
from
July 16, 2026 11:46
061f87b to
275cde0
Compare
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.
Problem
ipv6-mode: ipv4_onlyis parsed but never applied. Selecting "IPv4 only" has no effect on the generated sing-box config.Root cause
In
v2/config/builder.go,setInbound()derives IPv6 usage fromisIPv6Supported()instead of the user'sIPv6Mode. The code that would applyIPv6Modeis commented out (lines ~434-439 and ~459-469).isIPv6Supported()only resolves the IPv6 loopback:which succeeds on virtually any host — even one with no global IPv6. So
ipv6Enableis effectively alwaystrue: the TUN always receives an IPv6 address,auto_routecaptures the default IPv6 route, and inbounds bind to::— regardless of the IPv4-only choice.On hosts without global IPv6, browsers try AAAA first (Happy Eyeballs); packets enter the TUN but egress has no usable IPv6, so the TLS handshake is dropped (
ERR_CONNECTION_CLOSED). Example:yandex.ru(routed.ru -> direct) fails over IPv6 whilecurl -4succeeds. The only workaround is disabling IPv6 OS-wide.Fix
Same conversion pattern already used in
hiddify_option.go.Verified (built and tested, not just theory)
Built this patch into
hiddify-core.dll(from the v4.1.0 tree, Windows/amd64) and ran it under the installed Hiddify 4.1.1 on Windows 11, withipv6-mode: ipv4_onlyand TUN enabled.Before (stock core) — generated
current-config.json:After (patched core) — same settings:
Result: sites with AAAA records (e.g.
yandex.ru) now load correctly over IPv4 through the TUN, with no OS-level IPv6 workaround needed.Bonus: this also fixes
failed to start background coreon hosts where IPv6 is disabled OS-wide — the core no longer tries to bind::or assign an IPv6 address to the TUN.Notes
resolve-destination— worth restoring separately.dns.strategy: ipv4_only;getDNSServerOptionscurrently hardcodesprefer_ipv4, which does not drop AAAA.Related: hiddify/hiddify-app#2172 (same symptom — same version, same
ipv4_only, sites failing in VPN mode — reported without the IPv6 diagnosis).