Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMHSanaei <ho3ein.sanaei@gmail.com>2026-04-20 19:14:32 +0300
committerMHSanaei <ho3ein.sanaei@gmail.com>2026-04-20 19:14:32 +0300
commit094ea9faaae35b452ca3bd30b4b519da95ef984d (patch)
tree461e1d3752bd9967ce9cf17b8c161b38ebe8d971 /web/assets/js/model
parenteb16cca551a5880c9567b4d0a0d5fe5ca18b1c21 (diff)
tun: dual MTU, gateway, DNS, auto routing
Change TunSettings to support separate IPv4/IPv6 MTU values and add gateway, DNS, autoSystemRoutingTable and autoOutboundsInterface properties. Introduces _normalizeMtu to accept legacy single-value or array forms and provide sensible defaults. Update fromJson/toJson to handle new fields and preserve backward compatibility. Update tun form UI to expose MTU IPv4/IPv6 inputs, Gateway/DNS tag selects, Auto Routing Table and Auto Outbounds input.
Diffstat (limited to 'web/assets/js/model')
-rw-r--r--web/assets/js/model/inbound.js43
1 files changed, 37 insertions, 6 deletions
diff --git a/web/assets/js/model/inbound.js b/web/assets/js/model/inbound.js
index c4416e59..c94bd8d3 100644
--- a/web/assets/js/model/inbound.js
+++ b/web/assets/js/model/inbound.js
@@ -2723,29 +2723,60 @@ Inbound.TunSettings = class extends Inbound.Settings {
constructor(
protocol,
name = 'xray0',
- mtu = 1500,
- userLevel = 0
+ mtu = [1500, 1280],
+ gateway = [],
+ dns = [],
+ userLevel = 0,
+ autoSystemRoutingTable = [],
+ autoOutboundsInterface = 'auto'
) {
super(protocol);
this.name = name;
- this.mtu = mtu;
+ this.mtu = this._normalizeMtu(mtu);
+ this.gateway = Array.isArray(gateway) ? gateway : [];
+ this.dns = Array.isArray(dns) ? dns : [];
this.userLevel = userLevel;
+ this.autoSystemRoutingTable = Array.isArray(autoSystemRoutingTable) ? autoSystemRoutingTable : [];
+ this.autoOutboundsInterface = autoOutboundsInterface;
+ }
+
+ _normalizeMtu(mtu) {
+ if (!Array.isArray(mtu)) {
+ const single = Number(mtu) || 1500;
+ return [single, single];
+ }
+ if (mtu.length === 0) {
+ return [1500, 1280];
+ }
+ if (mtu.length === 1) {
+ const single = Number(mtu[0]) || 1500;
+ return [single, single];
+ }
+ return [Number(mtu[0]) || 1500, Number(mtu[1]) || 1280];
}
static fromJson(json = {}) {
return new Inbound.TunSettings(
Protocols.TUN,
json.name ?? 'xray0',
- json.mtu ?? json.MTU ?? 1500,
- json.userLevel ?? 0
+ json.mtu ?? json.MTU ?? [1500, 1280],
+ json.gateway ?? json.Gateway ?? [],
+ json.dns ?? json.DNS ?? [],
+ json.userLevel ?? 0,
+ json.autoSystemRoutingTable ?? [],
+ Object.prototype.hasOwnProperty.call(json, 'autoOutboundsInterface') ? json.autoOutboundsInterface : 'auto'
);
}
toJson() {
return {
name: this.name || 'xray0',
- mtu: this.mtu || 1500,
+ mtu: this._normalizeMtu(this.mtu),
+ gateway: this.gateway,
+ dns: this.dns,
userLevel: this.userLevel || 0,
+ autoSystemRoutingTable: this.autoSystemRoutingTable,
+ autoOutboundsInterface: this.autoOutboundsInterface,
};
}
}; \ No newline at end of file