Pull request: all: fix client id handling in querylog
Merge in DNS/adguard-home from 2607-querylog-client-id to master Closes #2607. Squashed commit of the following: commit 95367a82469af3b042489fb650b962b48cb73236 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Jan 28 19:02:02 2021 +0300 all: fix client, imp docs commit b652a7ef2373a75f7e897d29f5c9e36b0e076f8e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Jan 28 18:36:17 2021 +0300 all: fix client id handling in querylog
This commit is contained in:
parent
3af079a81b
commit
eeeb03839a
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
});
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
return cj, true
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue