mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-25 06:25:44 +03:00
* clients: remove an auto-client if a client with the same IP was added manually
This commit is contained in:
parent
95eeccde8f
commit
fcf37da312
1 changed files with 12 additions and 0 deletions
|
@ -206,6 +206,12 @@ func (clients *clientsContainer) Add(c Client) (bool, error) {
|
|||
}
|
||||
}
|
||||
|
||||
ch, ok := clients.ipHost[c.IP]
|
||||
if ok {
|
||||
c.WhoisInfo = ch.WhoisInfo
|
||||
delete(clients.ipHost, c.IP)
|
||||
}
|
||||
|
||||
clients.list[c.Name] = &c
|
||||
if len(c.IP) != 0 {
|
||||
clients.ipIndex[c.IP] = &c
|
||||
|
@ -312,6 +318,12 @@ func (clients *clientsContainer) AddHost(ip, host string, source clientSource) (
|
|||
clients.lock.Lock()
|
||||
defer clients.lock.Unlock()
|
||||
|
||||
// check index
|
||||
_, ok := clients.ipIndex[ip]
|
||||
if ok {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
// check index
|
||||
c, ok := clients.ipHost[ip]
|
||||
if ok && c.Source > source {
|
||||
|
|
Loading…
Reference in a new issue