mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-08-09 21:00:58 +00:00
fix: stop forcing port 53 on DoH/DoQ DNS server entries (#5950)
Object-form DNS server entries always received port: 53, because DnsServerObjectInnerSchema defaulted the port unconditionally and the DnsServerModal wire adapter always wrote it. Per Xray-core, encrypted schemes must not carry a port field; a non-standard port is embedded in the URL instead. Default the port to 53 only for non-encrypted addresses and omit it for the encrypted DNS schemes Xray dispatches without a port - https, https+local, h2c, h2c+local and quic+local - both in the Zod schema and in the modal's valuesToWire adapter. Schemes are matched case-insensitively to mirror Xray-core's EqualFold comparison. A shared isEncryptedDnsAddress helper backs both paths. Fixes #5920 Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
DnsQueryStrategySchema,
|
||||
DnsServerObjectInnerSchema,
|
||||
DnsServerObjectSchema,
|
||||
isEncryptedDnsAddress,
|
||||
type DnsServerObject,
|
||||
} from '@/schemas/dns';
|
||||
|
||||
@@ -109,7 +110,6 @@ function valuesToWire(values: DnsServerForm): DnsServerValue {
|
||||
|
||||
const out: Record<string, unknown> = {
|
||||
address: values.address,
|
||||
port: values.port,
|
||||
domains: values.domains.filter(Boolean),
|
||||
expectedIPs: values.expectedIPs.filter(Boolean),
|
||||
unexpectedIPs: values.unexpectedIPs.filter(Boolean),
|
||||
@@ -121,6 +121,7 @@ function valuesToWire(values: DnsServerForm): DnsServerValue {
|
||||
serveExpiredTTL: values.serveExpiredTTL,
|
||||
timeoutMs: values.timeoutMs,
|
||||
};
|
||||
if (!isEncryptedDnsAddress(values.address)) out.port = values.port;
|
||||
if (values.tag) out.tag = values.tag;
|
||||
if (values.clientIP) out.clientIP = values.clientIP;
|
||||
return out as DnsServerValue;
|
||||
|
||||
Reference in New Issue
Block a user