Skip to content

Commit 46ba4c4

Browse files
committed
fix getSubGroupClients for enable/disable and edit clients.
1 parent a787ab4 commit 46ba4c4

File tree

1 file changed

+40
-27
lines changed

1 file changed

+40
-27
lines changed

web/html/xui/inbounds.html

+40-27
Original file line numberDiff line numberDiff line change
@@ -1195,35 +1195,48 @@
11951195
}
11961196
},
11971197
getSubGroupClients(dbInbounds, currentClient) {
1198-
const response = {
1199-
inbounds: [],
1200-
clients: [],
1201-
editIds: []
1198+
const response = {
1199+
inbounds: [],
1200+
clients: [],
1201+
editIds: [],
1202+
};
1203+
1204+
if (!Array.isArray(dbInbounds) || dbInbounds.length === 0) {
1205+
return response;
1206+
}
1207+
if (!currentClient || !currentClient.subId) {
1208+
return response;
1209+
}
1210+
1211+
dbInbounds.forEach((dbInboundItem) => {
1212+
try {
1213+
const dbInbound = new DBInbound(dbInboundItem);
1214+
if (!dbInbound) {
1215+
return;
12021216
}
1203-
if (dbInbounds && dbInbounds.length > 0 && currentClient) {
1204-
dbInbounds.forEach((dbInboundItem) => {
1205-
const dbInbound = new DBInbound(dbInboundItem);
1206-
if (dbInbound) {
1207-
const inbound = dbInbound.toInbound();
1208-
if (inbound) {
1209-
const clients = inbound.clients;
1210-
if (clients.length > 0) {
1211-
clients.forEach((client) => {
1212-
if (client['subId'] === currentClient['subId']) {
1213-
client['inboundId'] = dbInboundItem.id
1214-
client['clientId'] = this.getClientId(dbInbound.protocol, client)
1215-
response.inbounds.push(dbInboundItem.id)
1216-
response.clients.push(client)
1217-
response.editIds.push(client['clientId'])
1218-
}
1219-
})
1220-
}
1221-
}
1222-
}
1223-
})
1217+
1218+
const inbound = dbInbound.toInbound();
1219+
if (!inbound || !Array.isArray(inbound.clients)) {
1220+
return;
12241221
}
1225-
return response;
1226-
},
1222+
1223+
inbound.clients.forEach((client) => {
1224+
if (client.subId === currentClient.subId) {
1225+
client.inboundId = dbInboundItem.id;
1226+
client.clientId = this.getClientId(dbInbound.protocol, client);
1227+
1228+
response.inbounds.push(dbInboundItem.id);
1229+
response.clients.push(client);
1230+
response.editIds.push(client.clientId);
1231+
}
1232+
});
1233+
} catch (error) {
1234+
console.error("Error processing dbInboundItem:", dbInboundItem, error);
1235+
}
1236+
});
1237+
1238+
return response;
1239+
},
12271240
getClientId(protocol, client) {
12281241
switch (protocol) {
12291242
case Protocols.TROJAN: return client.password;

0 commit comments

Comments
 (0)