Pull request: all: fix names of runtime clients on query log page
Updates #2929. Squashed commit of the following: commit f02111aac1e9d63732589b65b224613aa3240677 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 7 17:40:16 2021 +0300 all: fix names of runtime clients on query log page
This commit is contained in:
parent
c133b01ef7
commit
908452f883
|
@ -287,13 +287,11 @@ func toQueryLogWhois(wi *RuntimeClientWhoisInfo) (cw *querylog.ClientWhois) {
|
||||||
func (clients *clientsContainer) findMultiple(ids []string) (c *querylog.Client, err error) {
|
func (clients *clientsContainer) findMultiple(ids []string) (c *querylog.Client, err error) {
|
||||||
for _, id := range ids {
|
for _, id := range ids {
|
||||||
var name string
|
var name string
|
||||||
var foundIDs []string
|
|
||||||
whois := &querylog.ClientWhois{}
|
whois := &querylog.ClientWhois{}
|
||||||
|
|
||||||
c, ok := clients.Find(id)
|
c, ok := clients.Find(id)
|
||||||
if ok {
|
if ok {
|
||||||
name = c.Name
|
name = c.Name
|
||||||
foundIDs = c.IDs
|
|
||||||
} else {
|
} else {
|
||||||
var rc RuntimeClient
|
var rc RuntimeClient
|
||||||
rc, ok = clients.FindRuntimeClient(id)
|
rc, ok = clients.FindRuntimeClient(id)
|
||||||
|
@ -301,7 +299,7 @@ func (clients *clientsContainer) findMultiple(ids []string) (c *querylog.Client,
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
foundIDs = []string{rc.Host}
|
name = rc.Host
|
||||||
whois = toQueryLogWhois(rc.WhoisInfo)
|
whois = toQueryLogWhois(rc.WhoisInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,7 +310,6 @@ func (clients *clientsContainer) findMultiple(ids []string) (c *querylog.Client,
|
||||||
Name: name,
|
Name: name,
|
||||||
DisallowedRule: disallowedRule,
|
DisallowedRule: disallowedRule,
|
||||||
Whois: whois,
|
Whois: whois,
|
||||||
IDs: foundIDs,
|
|
||||||
Disallowed: disallowed,
|
Disallowed: disallowed,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,9 @@ package querylog
|
||||||
// Client is the information required by the query log to match against clients
|
// Client is the information required by the query log to match against clients
|
||||||
// during searches.
|
// during searches.
|
||||||
type Client struct {
|
type Client struct {
|
||||||
|
Whois *ClientWhois `json:"whois,omitempty"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
DisallowedRule string `json:"disallowed_rule"`
|
DisallowedRule string `json:"disallowed_rule"`
|
||||||
Whois *ClientWhois `json:"whois,omitempty"`
|
|
||||||
IDs []string `json:"ids"`
|
|
||||||
Disallowed bool `json:"disallowed"`
|
Disallowed bool `json:"disallowed"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@ func TestQueryLog_Search_findClient(t *testing.T) {
|
||||||
const unknownClientID = "client-2"
|
const unknownClientID = "client-2"
|
||||||
|
|
||||||
knownClient := &Client{
|
knownClient := &Client{
|
||||||
IDs: []string{knownClientID},
|
|
||||||
Name: knownClientName,
|
Name: knownClientName,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,5 +90,4 @@ func TestQueryLog_Search_findClient(t *testing.T) {
|
||||||
require.NotNil(t, gotClient)
|
require.NotNil(t, gotClient)
|
||||||
|
|
||||||
assert.Equal(t, knownClientName, gotClient.Name)
|
assert.Equal(t, knownClientName, gotClient.Name)
|
||||||
assert.Equal(t, []string{knownClientID}, gotClient.IDs)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1893,12 +1893,6 @@
|
||||||
set to true, and this string is empty, then the client IP is
|
set to true, and this string is empty, then the client IP is
|
||||||
disallowed by the "allowed IP list", that is it is not included in
|
disallowed by the "allowed IP list", that is it is not included in
|
||||||
the allowed list.
|
the allowed list.
|
||||||
'ids':
|
|
||||||
'description': >
|
|
||||||
IP, CIDR, MAC, or client ID.
|
|
||||||
'items':
|
|
||||||
'type': 'string'
|
|
||||||
'type': 'array'
|
|
||||||
'name':
|
'name':
|
||||||
'description': >
|
'description': >
|
||||||
Persistent client's name or an empty string if this is a runtime
|
Persistent client's name or an empty string if this is a runtime
|
||||||
|
|
Loading…
Reference in New Issue