From 87bcb67f8f5a57c765b4ea4928e45b4c5b3edfa0 Mon Sep 17 00:00:00 2001 From: Simon Zolin Date: Thu, 9 Jan 2020 16:42:38 +0300 Subject: [PATCH] * clients: remove WHOIS info for manually-added clients --- home/clients.go | 12 ------------ home/clients_http.go | 7 ------- home/clients_test.go | 4 ++-- 3 files changed, 2 insertions(+), 21 deletions(-) diff --git a/home/clients.go b/home/clients.go index 3b94edef..8fbf72a2 100644 --- a/home/clients.go +++ b/home/clients.go @@ -32,7 +32,6 @@ type Client struct { SafeSearchEnabled bool SafeBrowsingEnabled bool ParentalEnabled bool - WhoisInfo [][]string // [[key,value], ...] UseOwnBlockedServices bool // false: use global settings BlockedServices []string @@ -366,17 +365,6 @@ func (clients *clientsContainer) Add(c Client) (bool, error) { } } - // remove auto-clients with the same IP address, keeping WHOIS info if possible - for _, id := range c.IDs { - ch, ok := clients.ipHost[id] - if ok { - if len(c.WhoisInfo) == 0 { - c.WhoisInfo = ch.WhoisInfo - } - delete(clients.ipHost, id) - } - } - // update Name index clients.list[c.Name] = &c diff --git a/home/clients_http.go b/home/clients_http.go index 37336298..aaaef5e0 100644 --- a/home/clients_http.go +++ b/home/clients_http.go @@ -16,8 +16,6 @@ type clientJSON struct { SafeSearchEnabled bool `json:"safesearch_enabled"` SafeBrowsingEnabled bool `json:"safebrowsing_enabled"` - WhoisInfo map[string]interface{} `json:"whois_info"` - UseGlobalBlockedServices bool `json:"use_global_blocked_services"` BlockedServices []string `json:"blocked_services"` @@ -116,11 +114,6 @@ func clientToJSON(c *Client) clientJSON { Upstreams: c.Upstreams, } - - cj.WhoisInfo = make(map[string]interface{}) - for _, wi := range c.WhoisInfo { - cj.WhoisInfo[wi[0]] = wi[1] - } return cj } diff --git a/home/clients_test.go b/home/clients_test.go index e227d699..3315adb3 100644 --- a/home/clients_test.go +++ b/home/clients_test.go @@ -168,14 +168,14 @@ func TestClientsWhois(t *testing.T) { clients.SetWhoisInfo("1.1.1.1", whois) assert.True(t, clients.ipHost["1.1.1.1"].WhoisInfo[0][1] == "orgname-val") - // Check that we cannot set whois info on existing client + // Check that we cannot set whois info on a manually-added client c = Client{ IDs: []string{"1.1.1.2"}, Name: "client1", } _, _ = clients.Add(c) clients.SetWhoisInfo("1.1.1.2", whois) - assert.Nil(t, clients.idIndex["1.1.1.2"].WhoisInfo) + assert.True(t, clients.ipHost["1.1.1.2"] == nil) _ = clients.Del("client1") }