[PR #5950] [MERGED] fix: stop forcing port 53 on DoH/DoQ DNS server entries #6038

Closed
opened 2026-11-02 04:05:55 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/5950
Author: @mvanhorn
Created: 7/14/2026
Status: ✅ Merged
Merged: 7/14/2026
Merged by: @MHSanaei

Base: main ← Head: fix/5920-doh-doq-port


📝 Commits (1)

  • 8413059 fix: stop forcing port 53 on DoH/DoQ DNS server entries

📊 Changes

4 files changed (+55 additions, -4 deletions)

View changed files

📝 frontend/src/pages/xray/dns/DnsServerModal.tsx (+2 -1)
📝 frontend/src/schemas/dns.ts (+11 -2)
📝 frontend/src/test/__snapshots__/dns.test.ts.snap (+0 -1)
📝 frontend/src/test/dns.test.ts (+42 -0)

📄 Description

Summary

Stop the panel from writing port: 53 onto DNS-over-HTTPS / DoH-Local / DoQ server entries in the Preset DNS editor. Those encrypted schemes carry any non-standard port inside the URL, so a separate port field is invalid for them.

Why

As reported in #5920, DoH preset entries were being saved with port: 53. Two frontend paths injected it:

  • DnsServerObjectInnerSchema in frontend/src/schemas/dns.ts declared port: PortSchema.default(53), so every object-form entry got port: 53 even when the source JSON omitted a port. The repo's own golden fixture makes this visible: the quic+local:// DoQ entry in full.json has no port, yet the parsed snapshot showed port: 53.
  • valuesToWire in DnsServerModal.tsx always set out.port = values.port whenever an entry was emitted in object form, adding port: 53 to DoH/DoQ rows edited in the modal.

Xray-core treats https, https+local, h2c, h2c+local and quic+local as encrypted DNS transports and rejects a standalone port for them; the port belongs in the URL. The two paths above never accounted for the address scheme.

Closes #5920

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Documentation
  • Tests only
  • Build / CI / tooling
  • Other

Areas affected

  • Frontend (UI / panel pages)
  • Backend (API endpoints, login, settings)
  • Xray config generation
  • Subscription (share links / Clash / JSON)
  • Statistics / traffic counters
  • Database / migrations
  • Install / upgrade script
  • Docker image
  • Multi-node (sub-nodes)
  • Telegram bot

How was this tested?

A shared isEncryptedDnsAddress helper now backs both paths. The Zod schema defaults port to 53 only for non-encrypted addresses and omits it for the encrypted schemes; the modal's valuesToWire skips the port assignment for the same set. Schemes are matched case-insensitively to mirror Xray-core's EqualFold comparison.

Added unit tests in frontend/src/test/dns.test.ts covering: a plain address (8.8.8.8) and a tcp:// address still default to port: 53; https://, https+local://, h2c://, h2c+local:// and quic+local:// addresses omit the port; an uppercase scheme is treated the same; and an explicit port on an encrypted address is preserved. The dns.test.ts golden snapshot was regenerated so the quic+local:// fixture entry no longer shows port: 53.

Ran locally in frontend/: npm run typecheck, npm run lint, npm run test (849 tests pass), and npm run build all succeed.

Screenshots / recordings

No visible UI layout change; the fix affects the DNS config the panel emits. Behavior is covered by the unit tests and snapshot above.

Breaking changes

None. Non-encrypted DNS entries keep their existing port: 53 default, and explicit ports are always preserved.

AI assistance disclosure

AI was used for assistance.

  • Type of assistance: drafting the code change and its unit tests, and reviewing the diff.
  • Scope: limited to the DNS port handling fix in the two named frontend files plus its tests and snapshot.
  • Tools: an AI coding assistant.
  • Level of modification: the change was authored with AI assistance and validated locally (typecheck, lint, full test suite, and production build all pass).

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable).
  • go build ./... and the test suite pass locally. (Frontend-only change; no Go files touched.)
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass.
  • I updated the Wiki / README / API docs if user-facing behavior changed.
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/5950 **Author:** [@mvanhorn](https://github.com/mvanhorn) **Created:** 7/14/2026 **Status:** ✅ Merged **Merged:** 7/14/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix/5920-doh-doq-port` --- ### 📝 Commits (1) - [`8413059`](https://github.com/MHSanaei/3x-ui/commit/8413059028bb38b824564df85d6c19ac6e4be4f6) fix: stop forcing port 53 on DoH/DoQ DNS server entries ### 📊 Changes **4 files changed** (+55 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/pages/xray/dns/DnsServerModal.tsx` (+2 -1) 📝 `frontend/src/schemas/dns.ts` (+11 -2) 📝 `frontend/src/test/__snapshots__/dns.test.ts.snap` (+0 -1) 📝 `frontend/src/test/dns.test.ts` (+42 -0) </details> ### 📄 Description ## Summary Stop the panel from writing `port: 53` onto DNS-over-HTTPS / DoH-Local / DoQ server entries in the Preset DNS editor. Those encrypted schemes carry any non-standard port inside the URL, so a separate `port` field is invalid for them. ## Why As reported in #5920, DoH preset entries were being saved with `port: 53`. Two frontend paths injected it: - `DnsServerObjectInnerSchema` in `frontend/src/schemas/dns.ts` declared `port: PortSchema.default(53)`, so every object-form entry got `port: 53` even when the source JSON omitted a port. The repo's own golden fixture makes this visible: the `quic+local://` DoQ entry in `full.json` has no port, yet the parsed snapshot showed `port: 53`. - `valuesToWire` in `DnsServerModal.tsx` always set `out.port = values.port` whenever an entry was emitted in object form, adding `port: 53` to DoH/DoQ rows edited in the modal. Xray-core treats `https`, `https+local`, `h2c`, `h2c+local` and `quic+local` as encrypted DNS transports and rejects a standalone port for them; the port belongs in the URL. The two paths above never accounted for the address scheme. Closes #5920 ## Type of change - [x] Bug fix - [ ] New feature - [ ] Refactoring (no behavior change) - [ ] Documentation - [ ] Tests only - [ ] Build / CI / tooling - [ ] Other ## Areas affected - [x] Frontend (UI / panel pages) - [ ] Backend (API endpoints, login, settings) - [x] Xray config generation - [ ] Subscription (share links / Clash / JSON) - [ ] Statistics / traffic counters - [ ] Database / migrations - [ ] Install / upgrade script - [ ] Docker image - [ ] Multi-node (sub-nodes) - [ ] Telegram bot ## How was this tested? A shared `isEncryptedDnsAddress` helper now backs both paths. The Zod schema defaults `port` to 53 only for non-encrypted addresses and omits it for the encrypted schemes; the modal's `valuesToWire` skips the port assignment for the same set. Schemes are matched case-insensitively to mirror Xray-core's `EqualFold` comparison. Added unit tests in `frontend/src/test/dns.test.ts` covering: a plain address (`8.8.8.8`) and a `tcp://` address still default to `port: 53`; `https://`, `https+local://`, `h2c://`, `h2c+local://` and `quic+local://` addresses omit the port; an uppercase scheme is treated the same; and an explicit port on an encrypted address is preserved. The `dns.test.ts` golden snapshot was regenerated so the `quic+local://` fixture entry no longer shows `port: 53`. Ran locally in `frontend/`: `npm run typecheck`, `npm run lint`, `npm run test` (849 tests pass), and `npm run build` all succeed. ## Screenshots / recordings No visible UI layout change; the fix affects the DNS config the panel emits. Behavior is covered by the unit tests and snapshot above. ## Breaking changes None. Non-encrypted DNS entries keep their existing `port: 53` default, and explicit ports are always preserved. ## AI assistance disclosure AI was used for assistance. - Type of assistance: drafting the code change and its unit tests, and reviewing the diff. - Scope: limited to the DNS `port` handling fix in the two named frontend files plus its tests and snapshot. - Tools: an AI coding assistant. - Level of modification: the change was authored with AI assistance and validated locally (typecheck, lint, full test suite, and production build all pass). ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior (when applicable). - [ ] `go build ./...` and the test suite pass locally. (Frontend-only change; no Go files touched.) - [x] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. - [ ] I updated the Wiki / README / API docs if user-facing behavior changed. - [x] My commits follow the project's existing message style. - [x] I have no unrelated changes mixed into this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:05:55 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#6038
No description provided.