mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-12-15 19:31:45 +03:00
*(home): do not set whois-info for manually created clients
✅ Closes: Do not set WhoisInfo for manually created clients
This commit is contained in:
parent
cdd55139fa
commit
3a077717ae
@ -176,7 +176,7 @@ func (clients *clientsContainer) Exists(ip string, source clientSource) bool {
|
||||
clients.lock.Lock()
|
||||
defer clients.lock.Unlock()
|
||||
|
||||
_, ok := clients.idIndex[ip]
|
||||
_, ok := clients.findByIP(ip)
|
||||
if ok {
|
||||
return true
|
||||
}
|
||||
@ -484,10 +484,9 @@ func (clients *clientsContainer) SetWhoisInfo(ip string, info [][]string) {
|
||||
clients.lock.Lock()
|
||||
defer clients.lock.Unlock()
|
||||
|
||||
c, ok := clients.idIndex[ip]
|
||||
_, ok := clients.findByIP(ip)
|
||||
if ok {
|
||||
c.WhoisInfo = info
|
||||
log.Debug("Clients: set WHOIS info for client %s: %v", c.Name, c.WhoisInfo)
|
||||
log.Debug("Clients: client for %s is already created, ignore WHOIS info", ip)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -167,14 +167,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")
|
||||
|
||||
// set whois info on existing client
|
||||
// Check that we cannot set whois info on existing client
|
||||
c = Client{
|
||||
IDs: []string{"1.1.1.2"},
|
||||
Name: "client1",
|
||||
}
|
||||
_, _ = clients.Add(c)
|
||||
clients.SetWhoisInfo("1.1.1.2", whois)
|
||||
assert.True(t, clients.idIndex["1.1.1.2"].WhoisInfo[0][1] == "orgname-val")
|
||||
assert.Nil(t, clients.idIndex["1.1.1.2"].WhoisInfo)
|
||||
_ = clients.Del("client1")
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@ const (
|
||||
defaultServer = "whois.arin.net"
|
||||
defaultPort = "43"
|
||||
maxValueLength = 250
|
||||
whoisTTL = 1 * 60 * 60 // 1 hour
|
||||
)
|
||||
|
||||
// Whois - module context
|
||||
@ -205,8 +206,7 @@ func (w *Whois) Begin(ip string) {
|
||||
// TTL expired
|
||||
}
|
||||
expire = make([]byte, 8)
|
||||
const ttl = 1 * 60 * 60
|
||||
binary.BigEndian.PutUint64(expire, now+ttl)
|
||||
binary.BigEndian.PutUint64(expire, now+whoisTTL)
|
||||
_ = w.ipAddrs.Set([]byte(ip), expire)
|
||||
|
||||
log.Debug("Whois: adding %s", ip)
|
||||
|
Loading…
Reference in New Issue
Block a user