|
@@ -2723,29 +2723,60 @@ Inbound.TunSettings = class extends Inbound.Settings {
|
|
|
constructor(
|
|
constructor(
|
|
|
protocol,
|
|
protocol,
|
|
|
name = 'xray0',
|
|
name = 'xray0',
|
|
|
- mtu = 1500,
|
|
|
|
|
- userLevel = 0
|
|
|
|
|
|
|
+ mtu = [1500, 1280],
|
|
|
|
|
+ gateway = [],
|
|
|
|
|
+ dns = [],
|
|
|
|
|
+ userLevel = 0,
|
|
|
|
|
+ autoSystemRoutingTable = [],
|
|
|
|
|
+ autoOutboundsInterface = 'auto'
|
|
|
) {
|
|
) {
|
|
|
super(protocol);
|
|
super(protocol);
|
|
|
this.name = name;
|
|
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.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 = {}) {
|
|
static fromJson(json = {}) {
|
|
|
return new Inbound.TunSettings(
|
|
return new Inbound.TunSettings(
|
|
|
Protocols.TUN,
|
|
Protocols.TUN,
|
|
|
json.name ?? 'xray0',
|
|
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() {
|
|
toJson() {
|
|
|
return {
|
|
return {
|
|
|
name: this.name || 'xray0',
|
|
name: this.name || 'xray0',
|
|
|
- mtu: this.mtu || 1500,
|
|
|
|
|
|
|
+ mtu: this._normalizeMtu(this.mtu),
|
|
|
|
|
+ gateway: this.gateway,
|
|
|
|
|
+ dns: this.dns,
|
|
|
userLevel: this.userLevel || 0,
|
|
userLevel: this.userLevel || 0,
|
|
|
|
|
+ autoSystemRoutingTable: this.autoSystemRoutingTable,
|
|
|
|
|
+ autoOutboundsInterface: this.autoOutboundsInterface,
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|