mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #5774] [MERGED] fix(routing): allow dns.servers on private IPs past the geoip:private block rule #5982
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#5982
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/5774
Author: @volov-de
Created: 7/3/2026
Status: ✅ Merged
Merged: 7/8/2026
Merged by: @MHSanaei
Base:
main← Head:fix/dns-servers-private-ip-routing📝 Commits (4)
8277106fix(routing): allow dns.servers on private IPs past the geoip:private block rule5587124fix(routing): scope the DNS allow-rule to its port, guard against reorder/UI driftda23ecdfix: avoid size-computation overflow in allocation hintcedf508Merge branch 'main' into fix/dns-servers-private-ip-routing📊 Changes
3 files changed (+800 additions, -0 deletions)
View changed files
📝
internal/web/service/xray_setting.go(+3 -0)➕
internal/web/service/xray_setting_dns_routing.go(+386 -0)➕
internal/web/service/xray_setting_dns_routing_test.go(+411 -0)📄 Description
Summary
Auto-generates a
directallow-rule for any private/internal IP found indns.servers, inserted immediately before the panel's defaultgeoip:private -> blockedrouting rule, so Xray's own DNS lookups no longer get silently dropped by that rule.Why
Closes #5773.
Xray's own DNS client traffic is dispatched through the same routing table as proxied client traffic. When
dns.serverspoints at a private IP (e.g. a self-hosted AdGuard Home / Pi-hole reachable on the same Docker network as Xray — a common self-hosted setup) and the panel's defaultgeoip:privateblock rule is active, Xray's own DNS lookups get silently dropped by that rule. Xray then falls back to dialing destinations by raw hostname once its internal DNS attempt times out (~4s), so proxied connections still work — just with a multi-second stall added to every new domain-based connection, with no error surfaced anywhere. Root-caused with an Xray debug-log trace, details in the linked issue.Type of change
Areas affected
How was this tested?
EnsureDnsServerRouting(internal/web/service/xray_setting_dns_routing.go, mirrors the existingEnsureStatsRoutinghoist) is wired intoSaveXraySettingright afterEnsureStatsRouting.internal/web/service/xray_setting_dns_routing_test.go— 12 new cases: no-op paths (nodns.servers/ public IP / no block rule present), correct insertion position, both server-entry shapes (bare string and{address, port, ...}object), scheme/port/path stripping (including bracketed IPv6), skipping special/domain addresses (localhost,fakedns, plain hostnames), idempotency across repeated saves, in-place update when the server set changes, rule removal once no longer needed, and leaving hand-authored rules with extra matchers untouched.go test ./internal/web/service/...— all packages pass, no regressions.go vet ./internal/web/service/...andgofmt -lon the changed files — clean.go build ./internal/web/service/...— clean (built via agolang:1.26container; couldn't rungo build ./...for the full binary locally sinceinternal/web/web.go'sgo:embed all:distneeds a built frontend, which is unrelated to this change).Screenshots / recordings
N/A — backend-only change, no UI.
Breaking changes
None. The generated rule is only added when both a private
dns.serversIP and an existinggeoip:privateblock rule are present, and is kept in sync automatically; nothing changes for setups that don't have this combination.Checklist
go build ./...and the test suite pass locally. (see caveat above: built/tested the affected package directly rather than the full binary, since the frontend isn't part of this change)npm run lint,npm run typecheck, andnpm run buildpass. — N/A, no frontend changes.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.