mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-04 03:19:34 +00:00
fix(xray): align DNS outbound to spec and repair item-list rules UI
DNS outbound now mirrors xray-core's documented shape: rewriteNetwork / rewriteAddress / rewritePort / userLevel replace the legacy network / address / port keys, and unset values are dropped on the wire. Old configs are still accepted on read so saved configs migrate cleanly. While there, fix two latent bugs in repeat-item editors (DNS rules, Freedom noise, WireGuard peers): - The "+" buttons pushed plain objects into arrays of class instances, so toJson() crashed on the next read and the JSON tab silently went blank. Push proper class instances instead. - Each item heading lived outside any a-form-item, so the delete icon ignored the form's column grid and slumped left. Wrap the heading in a form-item with the standard offset wrapper-col and switch the flex to space-between so the icon sits at the right of the input column, in line with the fields below it.
This commit is contained in:
@@ -1292,7 +1292,6 @@ export class Outbound extends CommonClass {
|
||||
|
||||
hasAddressPort() {
|
||||
return [
|
||||
Protocols.DNS,
|
||||
Protocols.VMess,
|
||||
Protocols.VLESS,
|
||||
Protocols.Trojan,
|
||||
@@ -1846,15 +1845,17 @@ Outbound.DNSRule = class extends CommonClass {
|
||||
|
||||
Outbound.DNSSettings = class extends CommonClass {
|
||||
constructor(
|
||||
network = 'udp',
|
||||
address = '',
|
||||
port = 53,
|
||||
rewriteNetwork = '',
|
||||
rewriteAddress = '',
|
||||
rewritePort = 53,
|
||||
userLevel = 0,
|
||||
rules = []
|
||||
) {
|
||||
super();
|
||||
this.network = network;
|
||||
this.address = address;
|
||||
this.port = port;
|
||||
this.rewriteNetwork = rewriteNetwork;
|
||||
this.rewriteAddress = rewriteAddress;
|
||||
this.rewritePort = rewritePort;
|
||||
this.userLevel = userLevel;
|
||||
this.rules = Array.isArray(rules) ? rules.map(rule => rule instanceof Outbound.DNSRule ? rule : Outbound.DNSRule.fromJson(rule)) : [];
|
||||
}
|
||||
|
||||
@@ -1867,25 +1868,25 @@ Outbound.DNSSettings = class extends CommonClass {
|
||||
}
|
||||
|
||||
static fromJson(json = {}) {
|
||||
// Spec uses rewrite{Network,Address,Port}; older configs used the
|
||||
// bare network/address/port keys — accept both so existing saved
|
||||
// configs keep working after the migration.
|
||||
return new Outbound.DNSSettings(
|
||||
json.network,
|
||||
json.address,
|
||||
json.port,
|
||||
json.rewriteNetwork ?? json.network ?? '',
|
||||
json.rewriteAddress ?? json.address ?? '',
|
||||
Number(json.rewritePort ?? json.port ?? 53) || 53,
|
||||
Number(json.userLevel ?? 0) || 0,
|
||||
getDNSRulesFromJson(json),
|
||||
);
|
||||
}
|
||||
|
||||
toJson() {
|
||||
const json = {
|
||||
network: this.network,
|
||||
address: this.address,
|
||||
port: this.port,
|
||||
};
|
||||
|
||||
if (this.rules.length > 0) {
|
||||
json.rules = Outbound.DNSRule.toJsonArray(this.rules);
|
||||
}
|
||||
|
||||
const json = {};
|
||||
if (!ObjectUtil.isEmpty(this.rewriteNetwork)) json.rewriteNetwork = this.rewriteNetwork;
|
||||
if (!ObjectUtil.isEmpty(this.rewriteAddress)) json.rewriteAddress = this.rewriteAddress;
|
||||
if (this.rewritePort > 0) json.rewritePort = this.rewritePort;
|
||||
if (this.userLevel > 0) json.userLevel = this.userLevel;
|
||||
if (this.rules.length > 0) json.rules = Outbound.DNSRule.toJsonArray(this.rules);
|
||||
return json;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user