mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[PR #6918] [MERGED] fix(xray): open port 443 for private DoH servers in the DNS allow rule #6521
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#6521
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/6918
Author: @jayhemnani9910
Created: 10/24/2026
Status: ✅ Merged
Merged: 10/24/2026
Merged by: @MHSanaei
Base:
main← Head:fix/dns-allow-rule-doh-port📝 Commits (6)
d9d2dbafix(xray): open port 443 for private DoH servers in the DNS allow rule6605791Merge remote-tracking branch 'origin/main' into pr/6918f505afcfix(xray): ignore a DoH server's object port in the DNS allow rulecbd8933Merge remote-tracking branch 'origin/main' into pr/69181d320adstyle(xray): fit the DNS endpoint comments in two lines69b52c5Merge remote-tracking branch 'origin/main' into pr/6918📊 Changes
2 files changed (+61 additions, -17 deletions)
View changed files
📝
internal/web/service/xray_setting_dns_routing.go(+16 -17)📝
internal/web/service/xray_setting_dns_routing_test.go(+45 -0)📄 Description
Summary
When a DNS server is a private
https://orh2c://address, the auto-addedxui-dns-allowrule opens port 53 for it. Xray sends DoH to port 443, so the defaultgeoip:private -> blockedrule still drops every query. This makes those two schemes default to 443.Why
splitAddressHostPort(internal/web/service/xray_setting_dns_routing.go) strips the scheme and then defaults every address to 53. Xray-core sets the URL scheme tohttpsfor bothhttps://andh2c://(app/dns/nameserver_doh.go), so with no port in the address it dials 443.With
https://10.255.255.1/dns-queryas the DNS server (default template), saving gives{"ruleTag":"xui-dns-allow","ip":["10.255.255.1"],"port":"53","outboundTag":"direct"}and the core routes10.255.255.1:443toblocked. A DoH lookup through a SOCKS inbound then logstaking detour [blocked] for [tcp:10.255.255.1:443]and fails. The DNS form hides the port field for encrypted addresses, so a panel user can't work around it there. This hits self-hosted DoH resolvers on a LAN (AdGuard Home, Pi-hole with DoH).The
+localforms query outside routing, so they keep 53 as before; an explicit port still wins.Type of change
Areas affected
How was this tested?
TestEnsureDnsServerRouting_RemoteDohUsesHttpsPort:https://andh2c://without a port go into a 443 rule,https://...:8443keeps 8443. It fails on main.go test ./...(50 packages ok),go vet ./internal/web/service/.https://10.255.255.1/dns-queryandh2c://10.255.255.2/dns-query, thenPOST /panel/api/xray/routeTest:10.255.255.1:443and10.255.255.2:443->blocked.direct.Breaking changes
None.
Checklist
go build ./...and the test suite pass locally.npm run lint,npm run typecheck, andnpm run buildpass.golangci-lint run ./internal/web/service/...: 0 issues.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.