Skip to content

fix: align share-link Go DNS defaults with DoH/DoT (parity with Swift template)#20

Merged
mixc6763-prog merged 1 commit into
masterfrom
fix/share-link-go-dns-doh-dot
May 7, 2026
Merged

fix: align share-link Go DNS defaults with DoH/DoT (parity with Swift template)#20
mixc6763-prog merged 1 commit into
masterfrom
fix/share-link-go-dns-doh-dot

Conversation

@mixc6763-prog
Copy link
Copy Markdown
Collaborator

Summary

Fixes a missed leg of the v1.138.0 DNS-over-UDP/53 fix. The Swift RemoteConfigManager template was upgraded to DoH/DoT in commit 2ab6fda8, but the Go-side share-link conversion (clashConvertShareLinks in goClash/main.go) still emitted plain UDP/53 DNS. Users on this code path continued to hit dns resolve failed: i/o timeout against 1.1.1.1:53 / 8.8.8.8:53 — exactly the symptom v1.138.0 was supposed to eliminate.

Why It Matters

Two scenarios bite users on the Go path:

  1. Enterprise SSL VPN coexistence — clients like SangFor Easy Connect install a PF DNAT rule that redirects all dport 53 UDP traffic to an internal DNS proxy that can't resolve public Chinese domains. With plain UDP/53 fallback, every GeoSite/cn DIRECT route fails. (User report: #16 — log shows dial udp 1.1.1.1:53: i/o timeout against www.doubao.com, qq.com.)
  2. Polluted ISP DNS / UDP throttling — same class of failure documented in #2ab6fda8 commit message.

After upgrading to 1.138.0, users still saw failures because their share-link conversion flow went through the Go function, not the Swift template.

Change

One block of clashConvertShareLinks in goClash/main.go:

```diff
"dns": map[string]interface{}{
"enable": true,
"ipv6": false,
"enhanced-mode": "redir-host",

  • "nameserver": []string{
  • "default-nameserver": []string{
  • "114.114.114.114",
    "223.5.5.5",
    "119.29.29.29",
    },
  • "nameserver": []string{
  • "https://223.5.5.5/dns-query\",
  • "https://doh.pub/dns-query\",
  • "119.29.29.29",
  • "223.5.5.5",
  • "tls://223.5.5.5:853",
  • "tls://223.6.6.6:853",
  • },
    "fallback": []string{
  • "1.1.1.1",
  • "8.8.8.8",

Field-for-field parity with the v1.138.0 Swift template and with ClashFX's nameserverPolicyForConvertedProxies.

Local Verification

Rebuilt goClash.a after the patch:

Metric Before After
goClash.a size 173,193,192 B 173,193,928 B (+736 B, string-only)
https://doh.pub/dns-query in archive absent present
tls://223.5.5.5:853 in archive absent present
tls://223.6.6.6:853 in archive absent present
tls://1.1.1.1:853 in archive absent present
tls://8.8.8.8:853 in archive absent present

Build clean through arm64 + amd64 + universal lipo merge.

Impact

  • Easy Connect / corporate SSL VPN users can finally use DIRECT-routed CN domains.
  • Throttled / polluted UDP/53 networks no longer time out on initial DIRECT DNS.
  • No new dependencies, no API changes — runtime behavior identical for users on healthy plaintext UDP/53 networks (DoH/DoT is added before plaintext, mihomo races them).
  • No template-version migration needed — Swift path migration in v1.138.0 already covers existing user configs; this PR ensures new share-link imports go through the same DNS template.

… template)

The clashConvertShareLinks Go cgo function still emitted plain UDP/53
DNS in the auto-generated config when users imported share links
through the Go path:

    nameserver:  [223.5.5.5, 119.29.29.29]            # plain UDP/53
    fallback:    [1.1.1.1, 8.8.8.8]                   # plain UDP/53

This matches the same root cause fixed in v1.138.0 for the Swift
RemoteConfigManager template (commit 2ab6fda), but the Go path was
missed. Users on networks where UDP/53 is throttled, polluted, or
intercepted by enterprise SSL VPNs (e.g. SangFor Easy Connect, which
DNATs all UDP/53 traffic to its internal DNS proxy) hit:

    [TCP] dial DIRECT (match GeoSite/cn) ... www.doubao.com:443
      error: dns resolve failed: dial udp 1.1.1.1:53: i/o timeout

even after upgrading to v1.138.0, because the Go path still produced
the legacy DNS block.

Port the DoH/DoT block from ClashFX's nameserverPolicyForConvertedProxies
and align field-for-field with the v1.138.0 Swift template:

    nameserver: [https://doh.pub/dns-query, tls://223.5.5.5:853, ...]
    fallback:   [tls://1.1.1.1:853, tls://8.8.8.8:853, ...]

Both share-link conversion code paths (Swift and Go) now produce
identical DNS defaults that survive UDP/53 interception by enterprise
VPN clients.

Verified locally: rebuilt goClash.a contains all DoH/DoT URL strings;
size delta +736 bytes (string-only change, no new dependencies).

Refs #16
@mixc6763-prog mixc6763-prog merged commit 43184f8 into master May 7, 2026
1 check passed
@mixc6763-prog mixc6763-prog deleted the fix/share-link-go-dns-doh-dot branch May 7, 2026 07:38
mixc6763-prog added a commit to Clash-FX/ClashFX that referenced this pull request May 7, 2026
…PN UDP/53 interception (#73)

The default-nameserver list (used to bootstrap-resolve DNS server
domains like doh.pub before DoH/DoT can be used) included 8.8.8.8 in
two code paths:

  - applyTunConfig (Enhanced Mode/TUN bring-up)
  - clashWriteEnhancedConfig (writing enhanced config to disk)

When users run an enterprise SSL VPN that intercepts UDP/53 (e.g.
SangFor Easy Connect, which DNATs all dport 53 UDP to its internal
DNS proxy), the bootstrap query to 8.8.8.8:53 times out, blocking
DoH/DoT from coming online. nameserver/fallback lists already
preferred DoH (https://) + DoT (tls://...:853) so the in-flight
queries themselves are safe — but bootstrap is still UDP.

Replace 8.8.8.8 with 119.29.29.29 (Tencent DNSPod, domestic) for
parity with nameserverPolicyForConvertedProxies (lines 491-495,
already domestic-only). Domestic DNS UDP/53 is generally allowed
by enterprise VPN policies because corporate DNS itself usually
forwards to upstream domestic resolvers.

No new dependencies, no API change, no template-version bump
required. Companion to ClashX-Pro/ClashX#20 (which aligned that
project's share-link Go DNS defaults with our DoH/DoT design).

Co-authored-by: ClashFX Team <noreply@clashfx.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant