Pull request: 4939 Client update
Merge in DNS/adguard-home from 4939-client-upd to master Updates #4939. Squashed commit of the following: commit 34f35822afcc8020a674cd023a5907b5b3edcb65 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Fri Feb 10 14:01:57 2023 +0300 all: imp code, docs commit 1cd8767a38f6494c92fb5ceff26abe228fcca638 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Thu Feb 9 17:20:56 2023 +0300 all: different ttls commit 66d951ba3dd72cb698b89b432cbbbdd65cb421a2 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Thu Feb 9 14:24:47 2023 +0300 all: imp code commit 3fb8d08310296dad90783f13ba46a1d0ea11da2e Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Wed Feb 8 19:35:29 2023 +0300 home: fix rdns check logic
This commit is contained in:
@@ -67,15 +67,18 @@ func (c *Client) closeUpstreams() (err error) {
|
||||
|
||||
type clientSource uint
|
||||
|
||||
// Client sources. The order determines the priority.
|
||||
// Clients information sources. The order determines the priority.
|
||||
const (
|
||||
ClientSourceWHOIS clientSource = iota
|
||||
ClientSourceNone clientSource = iota
|
||||
ClientSourceWHOIS
|
||||
ClientSourceARP
|
||||
ClientSourceRDNS
|
||||
ClientSourceDHCP
|
||||
ClientSourceHostsFile
|
||||
ClientSourcePersistent
|
||||
)
|
||||
|
||||
// type check
|
||||
var _ fmt.Stringer = clientSource(0)
|
||||
|
||||
// String returns a human-readable name of cs.
|
||||
@@ -96,6 +99,7 @@ func (cs clientSource) String() (s string) {
|
||||
}
|
||||
}
|
||||
|
||||
// type check
|
||||
var _ encoding.TextMarshaler = clientSource(0)
|
||||
|
||||
// MarshalText implements encoding.TextMarshaler for the clientSource.
|
||||
@@ -332,23 +336,24 @@ func (clients *clientsContainer) onDHCPLeaseChanged(flags int) {
|
||||
}
|
||||
}
|
||||
|
||||
// exists checks if client with this IP address already exists.
|
||||
func (clients *clientsContainer) exists(ip netip.Addr, source clientSource) (ok bool) {
|
||||
// clientSource checks if client with this IP address already exists and returns
|
||||
// the source which updated it last. It returns [ClientSourceNone] if the
|
||||
// client doesn't exist.
|
||||
func (clients *clientsContainer) clientSource(ip netip.Addr) (src clientSource) {
|
||||
clients.lock.Lock()
|
||||
defer clients.lock.Unlock()
|
||||
|
||||
_, ok = clients.findLocked(ip.String())
|
||||
_, ok := clients.findLocked(ip.String())
|
||||
if ok {
|
||||
return true
|
||||
return ClientSourcePersistent
|
||||
}
|
||||
|
||||
rc, ok := clients.ipToRC[ip]
|
||||
if !ok {
|
||||
return false
|
||||
return ClientSourceNone
|
||||
}
|
||||
|
||||
// Return false if the new source has higher priority.
|
||||
return source <= rc.Source
|
||||
return rc.Source
|
||||
}
|
||||
|
||||
func toQueryLogWHOIS(wi *RuntimeClientWHOISInfo) (cw *querylog.ClientWHOIS) {
|
||||
|
||||
Reference in New Issue
Block a user