szmarczak / cacheable-lookup

A cacheable dns.lookup(…) that respects TTL :tada:
MIT License
193 stars 29 forks source link

return IPv6 by default #27

Closed hoilc closed 4 years ago

hoilc commented 4 years ago

got v11 introduced DNS cache as a default behavior by using cacheable-lookup.

Unexpectedly, it breaks http request in some IPv6-only environment where the DNS server support both IPv4 and IPv6.

By default, cacheable-lookup return IPv4 addresses which are unreachable from the server.

With the commonly used library glibc (http://man7.org/linux/man-pages/man3/getaddrinfo.3.html#NOTES), I expect IPv6 addresses without extra configurations in the same situation.

In other words, the following test is expected to be passed.

    {
        const CacheableLookup = mockedInterfaces({has4: false, has6: true});
        const cacheable = new CacheableLookup({resolver, customHostsPath: false});

        verify(t, await cacheable.lookupAsync('localhost'), {
            address: '::ffff:127.0.0.2',
            family: 6
        });
    }
szmarczak commented 4 years ago

Fixed in b2348d5aede36bdf625eba2aa17ca4dedb74c62b