mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-12-23 06:42:41 +00:00
fix: ensure testseed is initialized correctly for VLESS protocol and improve client handling in inbound modal
This commit is contained in:
parent
6247e79ac3
commit
a4909f83f0
4 changed files with 42 additions and 13 deletions
|
|
@ -1897,6 +1897,12 @@ Inbound.VLESSSettings = class extends Inbound.Settings {
|
||||||
}
|
}
|
||||||
|
|
||||||
static fromJson(json = {}) {
|
static fromJson(json = {}) {
|
||||||
|
// Ensure testseed is always initialized as an array
|
||||||
|
let testseed = [900, 500, 900, 256];
|
||||||
|
if (json.testseed && Array.isArray(json.testseed) && json.testseed.length >= 4) {
|
||||||
|
testseed = json.testseed;
|
||||||
|
}
|
||||||
|
|
||||||
const obj = new Inbound.VLESSSettings(
|
const obj = new Inbound.VLESSSettings(
|
||||||
Protocols.VLESS,
|
Protocols.VLESS,
|
||||||
(json.clients || []).map(client => Inbound.VLESSSettings.VLESS.fromJson(client)),
|
(json.clients || []).map(client => Inbound.VLESSSettings.VLESS.fromJson(client)),
|
||||||
|
|
@ -1904,7 +1910,7 @@ Inbound.VLESSSettings = class extends Inbound.Settings {
|
||||||
json.encryption,
|
json.encryption,
|
||||||
Inbound.VLESSSettings.Fallback.fromJson(json.fallbacks || []),
|
Inbound.VLESSSettings.Fallback.fromJson(json.fallbacks || []),
|
||||||
json.selectedAuth,
|
json.selectedAuth,
|
||||||
json.testseed && json.testseed.length >= 4 ? json.testseed : [900, 500, 900, 256]
|
testseed
|
||||||
);
|
);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@
|
||||||
<template v-if="inbound.settings.vlesses.some(c => c.flow === 'xtls-rprx-vision' || c.flow === 'xtls-rprx-vision-udp443')">
|
<template v-if="inbound.settings.vlesses.some(c => c.flow === 'xtls-rprx-vision' || c.flow === 'xtls-rprx-vision-udp443')">
|
||||||
<a-form :colon="false" :label-col="{ md: {span:8} }" :wrapper-col="{ md: {span:14} }">
|
<a-form :colon="false" :label-col="{ md: {span:8} }" :wrapper-col="{ md: {span:14} }">
|
||||||
<a-form-item label="Vision Seed">
|
<a-form-item label="Vision Seed">
|
||||||
<a-row :gutter="8">
|
<a-row :gutter="8" v-if="inbound.settings.testseed && inbound.settings.testseed.length >= 4">
|
||||||
<a-col :span="6">
|
<a-col :span="6">
|
||||||
<a-input-number v-model.number="inbound.settings.testseed[0]" :min="0" :max="9999" :style="{ width: '100%' }" placeholder="900" addon-before="[0]"></a-input-number>
|
<a-input-number v-model.number="inbound.settings.testseed[0]" :min="0" :max="9999" :style="{ width: '100%' }" placeholder="900" addon-before="[0]"></a-input-number>
|
||||||
</a-col>
|
</a-col>
|
||||||
|
|
|
||||||
|
|
@ -1128,8 +1128,11 @@
|
||||||
},
|
},
|
||||||
openEditClient(dbInboundId, client) {
|
openEditClient(dbInboundId, client) {
|
||||||
dbInbound = this.dbInbounds.find(row => row.id === dbInboundId);
|
dbInbound = this.dbInbounds.find(row => row.id === dbInboundId);
|
||||||
|
if (!dbInbound) return;
|
||||||
clients = this.getInboundClients(dbInbound);
|
clients = this.getInboundClients(dbInbound);
|
||||||
|
if (!clients || !Array.isArray(clients)) return;
|
||||||
index = this.findIndexOfClient(dbInbound.protocol, clients, client);
|
index = this.findIndexOfClient(dbInbound.protocol, clients, client);
|
||||||
|
if (index < 0) return;
|
||||||
clientModal.show({
|
clientModal.show({
|
||||||
title: '{{ i18n "pages.client.edit"}}',
|
title: '{{ i18n "pages.client.edit"}}',
|
||||||
okText: '{{ i18n "pages.client.submitEdit"}}',
|
okText: '{{ i18n "pages.client.submitEdit"}}',
|
||||||
|
|
@ -1144,11 +1147,14 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
findIndexOfClient(protocol, clients, client) {
|
findIndexOfClient(protocol, clients, client) {
|
||||||
|
if (!clients || !Array.isArray(clients) || !client) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
switch (protocol) {
|
switch (protocol) {
|
||||||
case Protocols.TROJAN:
|
case Protocols.TROJAN:
|
||||||
case Protocols.SHADOWSOCKS:
|
case Protocols.SHADOWSOCKS:
|
||||||
return clients.findIndex(item => item.password === client.password && item.email === client.email);
|
return clients.findIndex(item => item && item.password === client.password && item.email === client.email);
|
||||||
default: return clients.findIndex(item => item.id === client.id && item.email === client.email);
|
default: return clients.findIndex(item => item && item.id === client.id && item.email === client.email);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async addClient(clients, dbInboundId, modal) {
|
async addClient(clients, dbInboundId, modal) {
|
||||||
|
|
@ -1271,11 +1277,15 @@
|
||||||
},
|
},
|
||||||
showInfo(dbInboundId, client) {
|
showInfo(dbInboundId, client) {
|
||||||
dbInbound = this.dbInbounds.find(row => row.id === dbInboundId);
|
dbInbound = this.dbInbounds.find(row => row.id === dbInboundId);
|
||||||
|
if (!dbInbound) return;
|
||||||
index = 0;
|
index = 0;
|
||||||
if (dbInbound.isMultiUser()) {
|
if (dbInbound.isMultiUser()) {
|
||||||
inbound = dbInbound.toInbound();
|
inbound = dbInbound.toInbound();
|
||||||
clients = inbound.clients;
|
clients = inbound && inbound.clients ? inbound.clients : null;
|
||||||
|
if (clients && Array.isArray(clients)) {
|
||||||
index = this.findIndexOfClient(dbInbound.protocol, clients, client);
|
index = this.findIndexOfClient(dbInbound.protocol, clients, client);
|
||||||
|
if (index < 0) index = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
newDbInbound = this.checkFallback(dbInbound);
|
newDbInbound = this.checkFallback(dbInbound);
|
||||||
infoModal.show(newDbInbound, index);
|
infoModal.show(newDbInbound, index);
|
||||||
|
|
@ -1288,9 +1298,12 @@
|
||||||
async switchEnableClient(dbInboundId, client) {
|
async switchEnableClient(dbInboundId, client) {
|
||||||
this.loading()
|
this.loading()
|
||||||
dbInbound = this.dbInbounds.find(row => row.id === dbInboundId);
|
dbInbound = this.dbInbounds.find(row => row.id === dbInboundId);
|
||||||
|
if (!dbInbound) return;
|
||||||
inbound = dbInbound.toInbound();
|
inbound = dbInbound.toInbound();
|
||||||
clients = inbound.clients;
|
clients = inbound && inbound.clients ? inbound.clients : null;
|
||||||
|
if (!clients || !Array.isArray(clients)) return;
|
||||||
index = this.findIndexOfClient(dbInbound.protocol, clients, client);
|
index = this.findIndexOfClient(dbInbound.protocol, clients, client);
|
||||||
|
if (index < 0 || !clients[index]) return;
|
||||||
clients[index].enable = !clients[index].enable;
|
clients[index].enable = !clients[index].enable;
|
||||||
clientId = this.getClientId(dbInbound.protocol, clients[index]);
|
clientId = this.getClientId(dbInbound.protocol, clients[index]);
|
||||||
await this.updateClient(clients[index], dbInboundId, clientId);
|
await this.updateClient(clients[index], dbInboundId, clientId);
|
||||||
|
|
@ -1303,7 +1316,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getInboundClients(dbInbound) {
|
getInboundClients(dbInbound) {
|
||||||
return dbInbound.toInbound().clients;
|
if (!dbInbound) return null;
|
||||||
|
const inbound = dbInbound.toInbound();
|
||||||
|
return inbound && inbound.clients ? inbound.clients : null;
|
||||||
},
|
},
|
||||||
resetClientTraffic(client, dbInboundId, confirmation = true) {
|
resetClientTraffic(client, dbInboundId, confirmation = true) {
|
||||||
if (confirmation) {
|
if (confirmation) {
|
||||||
|
|
@ -1588,15 +1603,16 @@
|
||||||
|
|
||||||
// Listen for traffic updates
|
// Listen for traffic updates
|
||||||
window.wsClient.on('traffic', (payload) => {
|
window.wsClient.on('traffic', (payload) => {
|
||||||
if (payload && payload.clientTraffics) {
|
if (payload && payload.clientTraffics && Array.isArray(payload.clientTraffics)) {
|
||||||
// Update client traffic statistics
|
// Update client traffic statistics
|
||||||
payload.clientTraffics.forEach(clientTraffic => {
|
payload.clientTraffics.forEach(clientTraffic => {
|
||||||
const dbInbound = this.dbInbounds.find(ib => {
|
const dbInbound = this.dbInbounds.find(ib => {
|
||||||
|
if (!ib) return false;
|
||||||
const clients = this.getInboundClients(ib);
|
const clients = this.getInboundClients(ib);
|
||||||
return clients && clients.some(c => c.email === clientTraffic.email);
|
return clients && Array.isArray(clients) && clients.some(c => c && c.email === clientTraffic.email);
|
||||||
});
|
});
|
||||||
if (dbInbound && dbInbound.clientStats) {
|
if (dbInbound && dbInbound.clientStats && Array.isArray(dbInbound.clientStats)) {
|
||||||
const stats = dbInbound.clientStats.find(s => s.email === clientTraffic.email);
|
const stats = dbInbound.clientStats.find(s => s && s.email === clientTraffic.email);
|
||||||
if (stats) {
|
if (stats) {
|
||||||
stats.up = clientTraffic.up || stats.up;
|
stats.up = clientTraffic.up || stats.up;
|
||||||
stats.down = clientTraffic.down || stats.down;
|
stats.down = clientTraffic.down || stats.down;
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,13 @@
|
||||||
} else {
|
} else {
|
||||||
this.inbound = new Inbound();
|
this.inbound = new Inbound();
|
||||||
}
|
}
|
||||||
|
// Ensure testseed is initialized for VLESS protocol with vision flow
|
||||||
|
if (this.inbound.protocol === Protocols.VLESS && this.inbound.settings && this.inbound.settings.vlesses) {
|
||||||
|
const hasVisionFlow = this.inbound.settings.vlesses.some(c => c.flow === 'xtls-rprx-vision' || c.flow === 'xtls-rprx-vision-udp443');
|
||||||
|
if (hasVisionFlow && (!this.inbound.settings.testseed || !Array.isArray(this.inbound.settings.testseed) || this.inbound.settings.testseed.length < 4)) {
|
||||||
|
this.inbound.settings.testseed = [900, 500, 900, 256];
|
||||||
|
}
|
||||||
|
}
|
||||||
if (dbInbound) {
|
if (dbInbound) {
|
||||||
this.dbInbound = new DBInbound(dbInbound);
|
this.dbInbound = new DBInbound(dbInbound);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -60,7 +67,7 @@
|
||||||
return inModal.isEdit;
|
return inModal.isEdit;
|
||||||
},
|
},
|
||||||
get client() {
|
get client() {
|
||||||
return inModal.inbound.clients[0];
|
return inModal.inbound && inModal.inbound.clients && inModal.inbound.clients.length > 0 ? inModal.inbound.clients[0] : null;
|
||||||
},
|
},
|
||||||
get datepicker() {
|
get datepicker() {
|
||||||
return app.datepicker;
|
return app.datepicker;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue