diff options
| author | Sanaei <ho3ein.sanaei@gmail.com> | 2025-01-31 18:01:14 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-31 18:01:14 +0300 |
| commit | c8e8c97afc4960e4e080335df69ab6a3fb65d105 (patch) | |
| tree | 2d8b2f9c4d6f7d77ed726a54b8112d5bed5d44c6 /web/html/xui/inbounds.html | |
| parent | 3be204f272d68f0d6db1708fe3e0af84a675bfbc (diff) | |
| parent | 46ba4c451856d4bc4b0ee94c18081c83b2f1655a (diff) | |
Merge pull request #2652 from Incognito-Coder/main
Some Improvement
Diffstat (limited to 'web/html/xui/inbounds.html')
| -rw-r--r-- | web/html/xui/inbounds.html | 67 |
1 files changed, 40 insertions, 27 deletions
diff --git a/web/html/xui/inbounds.html b/web/html/xui/inbounds.html index 9dce8982..1cd1be1a 100644 --- a/web/html/xui/inbounds.html +++ b/web/html/xui/inbounds.html @@ -1195,35 +1195,48 @@ } }, getSubGroupClients(dbInbounds, currentClient) { - const response = { - inbounds: [], - clients: [], - editIds: [] + const response = { + inbounds: [], + clients: [], + editIds: [], + }; + + if (!Array.isArray(dbInbounds) || dbInbounds.length === 0) { + return response; + } + if (!currentClient || !currentClient.subId) { + return response; + } + + dbInbounds.forEach((dbInboundItem) => { + try { + const dbInbound = new DBInbound(dbInboundItem); + if (!dbInbound) { + return; } - if (dbInbounds && dbInbounds.length > 0 && currentClient) { - dbInbounds.forEach((dbInboundItem) => { - const dbInbound = new DBInbound(dbInboundItem); - if (dbInbound) { - const inbound = dbInbound.toInbound(); - if (inbound) { - const clients = inbound.clients; - if (clients.length > 0) { - clients.forEach((client) => { - if (client['subId'] === currentClient['subId']) { - client['inboundId'] = dbInboundItem.id - client['clientId'] = this.getClientId(dbInbound.protocol, client) - response.inbounds.push(dbInboundItem.id) - response.clients.push(client) - response.editIds.push(client['clientId']) - } - }) - } - } - } - }) + + const inbound = dbInbound.toInbound(); + if (!inbound || !Array.isArray(inbound.clients)) { + return; } - return response; - }, + + inbound.clients.forEach((client) => { + if (client.subId === currentClient.subId) { + client.inboundId = dbInboundItem.id; + client.clientId = this.getClientId(dbInbound.protocol, client); + + response.inbounds.push(dbInboundItem.id); + response.clients.push(client); + response.editIds.push(client.clientId); + } + }); + } catch (error) { + console.error("Error processing dbInboundItem:", dbInboundItem, error); + } + }); + + return response; + }, getClientId(protocol, client) { switch (protocol) { case Protocols.TROJAN: return client.password; |
