all: fix LAN hostname checking condition

The LAN hostname in question is FQDN, "." suffix must be trimmed before
checking.

While at it, also add tests for LAN/PTR query checking functions.
This commit is contained in:
Cuong Manh Le
2023-12-04 18:39:02 +07:00
committed by Cuong Manh Le
parent f9a3f4c045
commit 5897c174d3
5 changed files with 81 additions and 3 deletions
+3
View File
@@ -143,6 +143,9 @@ func (d *dhcp) lookupIPByHostname(name string, v6 bool) string {
if value == name {
if addr, err := netip.ParseAddr(key.(string)); err == nil && addr.Is6() == v6 {
ip = addr.String()
if addr.IsLoopback() { // Continue searching if this is loopback address.
return true
}
return false
}
}
+3
View File
@@ -69,6 +69,9 @@ func (m *mdns) lookupIPByHostname(name string, v6 bool) string {
if value == name {
if addr, err := netip.ParseAddr(key.(string)); err == nil && addr.Is6() == v6 {
ip = addr.String()
if addr.IsLoopback() { // Continue searching if this is loopback address.
return true
}
return false
}
}
+3
View File
@@ -104,6 +104,9 @@ func (p *ptrDiscover) lookupIPByHostname(name string, v6 bool) string {
if value == name {
if addr, err := netip.ParseAddr(key.(string)); err == nil && addr.Is6() == v6 {
ip = addr.String()
if addr.IsLoopback() { // Continue searching if this is loopback address.
return true
}
return false
}
}