From fcf37da3125aa613b96dd1ef08aee5a8d7cbb29f Mon Sep 17 00:00:00 2001 From: Simon Zolin Date: Mon, 23 Sep 2019 21:25:17 +0300 Subject: [PATCH] * clients: remove an auto-client if a client with the same IP was added manually --- home/clients.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/home/clients.go b/home/clients.go index 061a8935..ad246171 100644 --- a/home/clients.go +++ b/home/clients.go @@ -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 {