| ... | ... | @@ -869,21 +869,21 @@ fn linuxLookupName( |
| 869 | 869 | } else { |
| 870 | 870 | try linuxLookupNameFromHosts(addrs, canon, name, family, port); |
| 871 | 871 | if (addrs.items.len == 0) { |
| 872 | | try linuxLookupNameFromDnsSearch(addrs, canon, name, family, port); |
| 873 | | } |
| 874 | | if (addrs.items.len == 0) { |
| 875 | | // RFC 6761 Section 6.3 |
| 872 | // RFC 6761 Section 6.3.3 |
| 876 | 873 | // Name resolution APIs and libraries SHOULD recognize localhost |
| 877 | 874 | // names as special and SHOULD always return the IP loopback address |
| 878 | 875 | // for address queries and negative responses for all other query |
| 879 | 876 | // types. |
| 880 | 877 | |
| 881 | | // Check for equal to "localhost" or ends in ".localhost" |
| 882 | | if (mem.endsWith(u8, name, "localhost") and (name.len == "localhost".len or name[name.len - "localhost".len] == '.')) { |
| 878 | // Check for equal to "localhost(.)" or ends in ".localhost(.)" |
| 879 | const localhost = if (name[name.len - 1] == '.') "localhost." else "localhost"; |
| 880 | if (mem.endsWith(u8, name, localhost) and (name.len == localhost.len or name[name.len - localhost.len] == '.')) { |
| 883 | 881 | try addrs.append(LookupAddr{ .addr = .{ .in = Ip4Address.parse("127.0.0.1", port) catch unreachable } }); |
| 884 | 882 | try addrs.append(LookupAddr{ .addr = .{ .in6 = Ip6Address.parse("::1", port) catch unreachable } }); |
| 885 | 883 | return; |
| 886 | 884 | } |
| 885 | |
| 886 | try linuxLookupNameFromDnsSearch(addrs, canon, name, family, port); |
| 887 | 887 | } |
| 888 | 888 | } |
| 889 | 889 | } else { |