DNS hosts: Support return RCode

This commit is contained in:
j2rong4cn 2025-05-01 10:44:39 +08:00
parent fbae89d017
commit 74fa9b972f
4 changed files with 70 additions and 19 deletions

View file

@ -204,7 +204,9 @@ func (s *DNS) LookupIP(domain string, option dns.IPOption) ([]net.IP, uint32, er
}
// Static host lookup
switch addrs := s.hosts.Lookup(domain, option); {
switch addrs, err := s.hosts.Lookup(domain, option); {
case err != nil:
return nil, 0, err
case addrs == nil: // Domain not recorded in static host
break
case len(addrs) == 0: // Domain recorded, but no valid IP returned (e.g. IPv4 address with only IPv6 enabled)