internal/clientinfo: use ptr cache when listing clients

This commit is contained in:
Cuong Manh Le
2023-07-27 20:39:40 +00:00
committed by Cuong Manh Le
parent 39a2cab051
commit 6e27f877ff
3 changed files with 16 additions and 1 deletions
+8
View File
@@ -229,6 +229,14 @@ func (t *Table) lookupHostnameAll(ip, mac string) []*hostnameEntry {
var res []*hostnameEntry
for _, r := range t.hostnameResolvers {
src := r.String()
// For ptrDiscover, lookup hostname may block due to server unavailable,
// so only lookup from cache to prevent timeout reached.
if ptrResolver, ok := r.(*ptrDiscover); ok {
if name := ptrResolver.lookupHostnameFromCache(ip); name != "" {
res = append(res, &hostnameEntry{name: name, src: src})
}
continue
}
if name := r.LookupHostnameByIP(ip); name != "" {
res = append(res, &hostnameEntry{name: name, src: src})
continue