mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-05-08 14:36:13 +00:00
fix(tun): use single mtu number per Xray spec
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -3197,7 +3197,7 @@ Inbound.TunSettings = class extends Inbound.Settings {
|
||||
constructor(
|
||||
protocol,
|
||||
name = 'xray0',
|
||||
mtu = [1500, 1280],
|
||||
mtu = 1500,
|
||||
gateway = [],
|
||||
dns = [],
|
||||
userLevel = 0,
|
||||
@@ -3206,7 +3206,7 @@ Inbound.TunSettings = class extends Inbound.Settings {
|
||||
) {
|
||||
super(protocol);
|
||||
this.name = name;
|
||||
this.mtu = this._normalizeMtu(mtu);
|
||||
this.mtu = Number(mtu) || 1500;
|
||||
this.gateway = Array.isArray(gateway) ? gateway : [];
|
||||
this.dns = Array.isArray(dns) ? dns : [];
|
||||
this.userLevel = userLevel;
|
||||
@@ -3214,26 +3214,13 @@ Inbound.TunSettings = class extends Inbound.Settings {
|
||||
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 = {}) {
|
||||
const rawMtu = json.mtu ?? json.MTU;
|
||||
const mtu = Array.isArray(rawMtu) ? rawMtu[0] : rawMtu;
|
||||
return new Inbound.TunSettings(
|
||||
Protocols.TUN,
|
||||
json.name ?? 'xray0',
|
||||
json.mtu ?? json.MTU ?? [1500, 1280],
|
||||
mtu ?? 1500,
|
||||
json.gateway ?? json.Gateway ?? [],
|
||||
json.dns ?? json.DNS ?? [],
|
||||
json.userLevel ?? 0,
|
||||
@@ -3245,7 +3232,7 @@ Inbound.TunSettings = class extends Inbound.Settings {
|
||||
toJson() {
|
||||
return {
|
||||
name: this.name || 'xray0',
|
||||
mtu: this._normalizeMtu(this.mtu),
|
||||
mtu: Number(this.mtu) || 1500,
|
||||
gateway: this.gateway,
|
||||
dns: this.dns,
|
||||
userLevel: this.userLevel || 0,
|
||||
|
||||
@@ -18,14 +18,11 @@
|
||||
<template slot="title">
|
||||
<span>{{ i18n "pages.xray.tun.mtuDesc" }}</span>
|
||||
</template>
|
||||
MTU IPv4
|
||||
MTU
|
||||
<a-icon type="question-circle"></a-icon>
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<a-input-number v-model.number="inbound.settings.mtu[0]" :min="1" :max="9000" placeholder="1500"></a-input-number>
|
||||
</a-form-item>
|
||||
<a-form-item label="MTU IPv6">
|
||||
<a-input-number v-model.number="inbound.settings.mtu[1]" :min="1" :max="9000" placeholder="1280"></a-input-number>
|
||||
<a-input-number v-model.number="inbound.settings.mtu" :min="1" :max="9000" placeholder="1500"></a-input-number>
|
||||
</a-form-item>
|
||||
<a-form-item label="Gateway">
|
||||
<a-select mode="tags" v-model="inbound.settings.gateway" :style="{ width: '100%' }" :token-separators="[',']"
|
||||
|
||||
Reference in New Issue
Block a user