diff --git a/client/src/actions/queryLogs.js b/client/src/actions/queryLogs.js index de8af4a3..076a9008 100644 --- a/client/src/actions/queryLogs.js +++ b/client/src/actions/queryLogs.js @@ -12,7 +12,7 @@ const enrichWithClientInfo = async (logs) => { if (Object.keys(clientsParams).length > 0) { const clients = await apiClient.findClients(clientsParams); - return addClientInfo(logs, clients, 'client'); + return addClientInfo(logs, clients, 'client_id', 'client'); } return logs; diff --git a/client/src/helpers/helpers.js b/client/src/helpers/helpers.js index 2acf5315..f8f276c8 100644 --- a/client/src/helpers/helpers.js +++ b/client/src/helpers/helpers.js @@ -128,12 +128,21 @@ export const normalizeTopStats = (stats) => ( })) ); -export const addClientInfo = (data, clients, param) => data.map((row) => { - const clientIp = row[param]; - const info = clients.find((item) => item[clientIp]) || ''; +export const addClientInfo = (data, clients, ...params) => data.map((row) => { + let info = ''; + params.find((param) => { + const id = row[param]; + if (id) { + const client = clients.find((item) => item[id]) || ''; + info = client?.[id] ?? ''; + } + + return info; + }); + return { ...row, - info: info?.[clientIp] ?? '', + info, }; }); diff --git a/internal/home/clientshttp.go b/internal/home/clientshttp.go index 42d7fa20..edeaf585 100644 --- a/internal/home/clientshttp.go +++ b/internal/home/clientshttp.go @@ -264,8 +264,12 @@ func (clients *clientsContainer) handleFindClient(w http.ResponseWriter, r *http // findTemporary looks up the IP in temporary storages, like autohosts or // blocklists. func (clients *clientsContainer) findTemporary(ip net.IP, idStr string) (cj clientJSON, found bool) { + if ip == nil { + return cj, false + } + ch, ok := clients.FindAutoClient(idStr) - if !ok && ip != nil { + if !ok { // It is still possible that the IP used to be in the runtime // clients list, but then the server was reloaded. So, check // the DNS server's blocked IP list. @@ -286,9 +290,7 @@ func (clients *clientsContainer) findTemporary(ip net.IP, idStr string) (cj clie } cj = clientHostToJSON(idStr, ch) - if ip != nil { - cj.Disallowed, cj.DisallowedRule = clients.dnsServer.IsBlockedIP(ip) - } + cj.Disallowed, cj.DisallowedRule = clients.dnsServer.IsBlockedIP(ip) return cj, true }