Skip to content

Commit

Permalink
Pull request: all: fix names of runtime clients on query log page
Browse files Browse the repository at this point in the history
Updates AdguardTeam#2929.

Squashed commit of the following:

commit f02111a
Author: Ainar Garipov <[email protected]>
Date:   Wed Apr 7 17:40:16 2021 +0300

    all: fix names of runtime clients on query log page
  • Loading branch information
ainar-g committed Apr 7, 2021
1 parent c133b01 commit 908452f
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 14 deletions.
5 changes: 1 addition & 4 deletions internal/home/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,21 +287,19 @@ func toQueryLogWhois(wi *RuntimeClientWhoisInfo) (cw *querylog.ClientWhois) {
func (clients *clientsContainer) findMultiple(ids []string) (c *querylog.Client, err error) {
for _, id := range ids {
var name string
var foundIDs []string
whois := &querylog.ClientWhois{}

c, ok := clients.Find(id)
if ok {
name = c.Name
foundIDs = c.IDs
} else {
var rc RuntimeClient
rc, ok = clients.FindRuntimeClient(id)
if !ok {
continue
}

foundIDs = []string{rc.Host}
name = rc.Host
whois = toQueryLogWhois(rc.WhoisInfo)
}

Expand All @@ -312,7 +310,6 @@ func (clients *clientsContainer) findMultiple(ids []string) (c *querylog.Client,
Name: name,
DisallowedRule: disallowedRule,
Whois: whois,
IDs: foundIDs,
Disallowed: disallowed,
}, nil
}
Expand Down
3 changes: 1 addition & 2 deletions internal/querylog/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ package querylog
// Client is the information required by the query log to match against clients
// during searches.
type Client struct {
Whois *ClientWhois `json:"whois,omitempty"`
Name string `json:"name"`
DisallowedRule string `json:"disallowed_rule"`
Whois *ClientWhois `json:"whois,omitempty"`
IDs []string `json:"ids"`
Disallowed bool `json:"disallowed"`
}

Expand Down
2 changes: 0 additions & 2 deletions internal/querylog/search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ func TestQueryLog_Search_findClient(t *testing.T) {
const unknownClientID = "client-2"

knownClient := &Client{
IDs: []string{knownClientID},
Name: knownClientName,
}

Expand Down Expand Up @@ -91,5 +90,4 @@ func TestQueryLog_Search_findClient(t *testing.T) {
require.NotNil(t, gotClient)

assert.Equal(t, knownClientName, gotClient.Name)
assert.Equal(t, []string{knownClientID}, gotClient.IDs)
}
6 changes: 0 additions & 6 deletions openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1893,12 +1893,6 @@
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
the allowed list.
'ids':
'description': >
IP, CIDR, MAC, or client ID.
'items':
'type': 'string'
'type': 'array'
'name':
'description': >
Persistent client's name or an empty string if this is a runtime
Expand Down

0 comments on commit 908452f

Please sign in to comment.