mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5920] [Bug]: Incorrect DNS Port Configuration for DoH Presets #4107
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#4107
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?
Originally created by @parsa-fathi on GitHub (Jul 13, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5920
Describe the bug
Bug Report: Incorrect DNS Port Configuration for DoH Presets
Description
In the panel's Preset DNS section, the predefined DNS records for DNS over HTTPS (DoH) are configured with port
53.According to the Xray Core documentation, the
portfield should not be used for DoH, DoHL, or DoQ modes. The port must be specified directly inside the URL if a non-standard port is required.Steps to Reproduce
port: 53.Expected Behavior
For DoH DNS entries:
portfield should be omitted.Example:
or for a custom port:
Actual Behavior
DoH preset entries are generated with:
which is invalid according to Xray Core documentation.
Reference
https://xtls.github.io/en/config/dns.html#dnsobject
Xray Core documentation:
Impact
This may cause invalid DNS configuration generation or unexpected behavior when using DoH-based DNS resolvers.
How to reproduce the problem
port: 53.Expected behavior
No response
Actual behavior
No response
Relevant logs
Screenshots
No response
3x-ui version
3.5.0
Xray-core version
No response
How did you install 3x-ui?
install.sh script
Operating system
Ubuntu26
Which parts of the panel are affected?
No response
Browser (only if it is a UI bug)
No response
Is the panel behind a reverse proxy or CDN?
None
Before submitting
@github-actions[bot] commented on GitHub (Jul 13, 2026):
Confirmed as a real defect, but not quite where the reproduction steps point — clicking "Install" on a DoH/DoQ preset does not itself attach a port. I traced the full path from preset to saved config.
What "Install" actually produces:
PRESETSinfrontend/src/pages/xray/dns/DnsPresetsModal.tsx(lines 37-66) stores DoH/DoQ entries as bare address strings, e.g.'https://cloudflare-dns.com/dns-query'.onPresetInstallinfrontend/src/pages/xray/dns/DnsTab.tsx:180-185copies that string array straight intodns.serverswith no transformation, so right after clicking "Install" the entry is just"https://cloudflare-dns.com/dns-query"— noportkey, matching the "Expected Behavior" in this report.Where
port: 53actually gets attached: as soon as a DoH/DoQ entry becomes an object instead of a bare string,portis force-defaulted to 53 with no check on the address scheme, in two places:frontend/src/schemas/dns.ts:19—DnsServerObjectInnerSchemadeclaresport: PortSchema.default(53). Any object-form server entry parsed through this schema getsport: 53injected even when the source JSON omits it. The repo's own test data proves this: fixturefrontend/src/test/golden/fixtures/dns/full.json(lines 32-40) has aquic+local://dns.adguard.com(DoQ) entry with noportkey, but the corresponding parsed snapshotfrontend/src/test/__snapshots__/dns.test.ts.snap(line 44) shows"port": 53added to that same entry.frontend/src/pages/xray/dns/DnsServerModal.tsx, functionvaluesToWire(lines 93-127): it always setsout.port = values.portwhenever any other field differs from its default (tag, domains, queryStrategy, skipFallback, clientIP, etc.), regardless of whetheraddressstarts withhttps://,https+local://, orquic+local://. Concrete repro: install a DoH/DoQ preset, open "Edit" on that row, change any other field (e.g. add a tag), confirm — the saved entry becomes{"address": "https://.../dns-query", "port": 53, ...}, matching this report's "Actual Behavior" exactly.Title: DNS server schema and edit form force-default
port: 53on DoH/DoQ addresses regardless of URI schemeSeverity: Low
Category: Correctness
Why this matters: per the Xray-core docs you cited,
portis invalid for DOH/DOHL/DOQL entries and should be embedded in the URL instead. Once a DoH/DoQ entry (preset-installed or manually added) is edited with any other non-default field, the panel writes aportfield onto it that shouldn't be there. I did not verify xray-core's actual tolerance for a superfluousportnext to a DoH/DoQ address (hard rejection vs. silently ignored field), so I can't confirm whether this breaks DNS resolution outright or is a harmless no-op — the severity above reflects spec non-compliance, not a confirmed runtime failure.Recommendation: make the
portdefault conditional on theaddressscheme in both places — skip the.default(53)fill inDnsServerObjectInnerSchema(frontend/src/schemas/dns.ts:19) and skip settingout.portinvaluesToWire(frontend/src/pages/xray/dns/DnsServerModal.tsx:110-126) whenaddressstarts withhttps://,https+local://, orquic+local://. No change is needed inDnsPresetsModal.tsx/DnsTab.tsx, since the plain-install path already stays string-only.Example:
Confidence: high on the mechanism described above (verified directly against source and the repo's own golden-fixture/snapshot test). Lower on real-world impact at the Xray-core runtime layer, which I did not inspect in this pass.
@MHSanaei for a fix decision.
This reply was generated automatically; a maintainer may follow up.
@mvanhorn commented on GitHub (Jul 14, 2026):
Opened #5950 to address this. It stops the panel from writing
port: 53onto DoH / DoH-Local / DoQ (and h2c) DNS server entries, defaulting the port only for non-encrypted schemes. Includes unit tests and a regenerated snapshot.