internal/clientinfo: check hostname mapping for both ipv4/ipv6

This commit is contained in:
Cuong Manh Le
2024-04-19 07:49:56 +07:00
committed by Cuong Manh Le
parent dd9f2465be
commit da01a146d2
2 changed files with 8 additions and 7 deletions
+6 -4
View File
@@ -328,11 +328,13 @@ func (t *Table) LookupRFC1918IPv4(mac string) string {
}
// LocalHostname returns the localhost hostname associated with loopback IP.
func (t *Table) LocalHostname(v6 bool) string {
if v6 {
return t.LookupHostname(ipv6Loopback, "")
func (t *Table) LocalHostname() string {
for _, ip := range []string{ipV4Loopback, ipv6Loopback} {
if name := t.LookupHostname(ip, ""); name != "" {
return name
}
}
return t.LookupHostname(ipV4Loopback, "")
return ""
}
type macEntry struct {