mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-05-13 09:36:05 +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:
parent
42b2ebc00b
commit
39bf31bd56
2 changed files with 8 additions and 24 deletions
|
|
@ -3197,7 +3197,7 @@ Inbound.TunSettings = class extends Inbound.Settings {
|
||||||
constructor(
|
constructor(
|
||||||
protocol,
|
protocol,
|
||||||
name = 'xray0',
|
name = 'xray0',
|
||||||
mtu = [1500, 1280],
|
mtu = 1500,
|
||||||
gateway = [],
|
gateway = [],
|
||||||
dns = [],
|
dns = [],
|
||||||
userLevel = 0,
|
userLevel = 0,
|
||||||
|
|
@ -3206,7 +3206,7 @@ Inbound.TunSettings = class extends Inbound.Settings {
|
||||||
) {
|
) {
|
||||||
super(protocol);
|
super(protocol);
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.mtu = this._normalizeMtu(mtu);
|
this.mtu = Number(mtu) || 1500;
|
||||||
this.gateway = Array.isArray(gateway) ? gateway : [];
|
this.gateway = Array.isArray(gateway) ? gateway : [];
|
||||||
this.dns = Array.isArray(dns) ? dns : [];
|
this.dns = Array.isArray(dns) ? dns : [];
|
||||||
this.userLevel = userLevel;
|
this.userLevel = userLevel;
|
||||||
|
|
@ -3214,26 +3214,13 @@ Inbound.TunSettings = class extends Inbound.Settings {
|
||||||
this.autoOutboundsInterface = autoOutboundsInterface;
|
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 = {}) {
|
||||||
|
const rawMtu = json.mtu ?? json.MTU;
|
||||||
|
const mtu = Array.isArray(rawMtu) ? rawMtu[0] : rawMtu;
|
||||||
return new Inbound.TunSettings(
|
return new Inbound.TunSettings(
|
||||||
Protocols.TUN,
|
Protocols.TUN,
|
||||||
json.name ?? 'xray0',
|
json.name ?? 'xray0',
|
||||||
json.mtu ?? json.MTU ?? [1500, 1280],
|
mtu ?? 1500,
|
||||||
json.gateway ?? json.Gateway ?? [],
|
json.gateway ?? json.Gateway ?? [],
|
||||||
json.dns ?? json.DNS ?? [],
|
json.dns ?? json.DNS ?? [],
|
||||||
json.userLevel ?? 0,
|
json.userLevel ?? 0,
|
||||||
|
|
@ -3245,7 +3232,7 @@ Inbound.TunSettings = class extends Inbound.Settings {
|
||||||
toJson() {
|
toJson() {
|
||||||
return {
|
return {
|
||||||
name: this.name || 'xray0',
|
name: this.name || 'xray0',
|
||||||
mtu: this._normalizeMtu(this.mtu),
|
mtu: Number(this.mtu) || 1500,
|
||||||
gateway: this.gateway,
|
gateway: this.gateway,
|
||||||
dns: this.dns,
|
dns: this.dns,
|
||||||
userLevel: this.userLevel || 0,
|
userLevel: this.userLevel || 0,
|
||||||
|
|
|
||||||
|
|
@ -18,14 +18,11 @@
|
||||||
<template slot="title">
|
<template slot="title">
|
||||||
<span>{{ i18n "pages.xray.tun.mtuDesc" }}</span>
|
<span>{{ i18n "pages.xray.tun.mtuDesc" }}</span>
|
||||||
</template>
|
</template>
|
||||||
MTU IPv4
|
MTU
|
||||||
<a-icon type="question-circle"></a-icon>
|
<a-icon type="question-circle"></a-icon>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
</template>
|
</template>
|
||||||
<a-input-number v-model.number="inbound.settings.mtu[0]" :min="1" :max="9000" placeholder="1500"></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="MTU IPv6">
|
|
||||||
<a-input-number v-model.number="inbound.settings.mtu[1]" :min="1" :max="9000" placeholder="1280"></a-input-number>
|
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="Gateway">
|
<a-form-item label="Gateway">
|
||||||
<a-select mode="tags" v-model="inbound.settings.gateway" :style="{ width: '100%' }" :token-separators="[',']"
|
<a-select mode="tags" v-model="inbound.settings.gateway" :style="{ width: '100%' }" :token-separators="[',']"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue