diff options
Diffstat (limited to 'ext/node/polyfills/internal_binding')
| -rw-r--r-- | ext/node/polyfills/internal_binding/cares_wrap.ts | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/ext/node/polyfills/internal_binding/cares_wrap.ts b/ext/node/polyfills/internal_binding/cares_wrap.ts index 6feb7faf0..cbfea40b2 100644 --- a/ext/node/polyfills/internal_binding/cares_wrap.ts +++ b/ext/node/polyfills/internal_binding/cares_wrap.ts @@ -75,11 +75,18 @@ export function getaddrinfo( const recordTypes: ("A" | "AAAA")[] = []; - if (family === 0 || family === 4) { + if (family === 6) { + recordTypes.push("AAAA"); + } else if (family === 4) { recordTypes.push("A"); - } - if (family === 0 || family === 6) { + } else if (family === 0 && hostname === "localhost") { + // Ipv6 is preferred over Ipv4 for localhost recordTypes.push("AAAA"); + recordTypes.push("A"); + } else if (family === 0) { + // Only get Ipv4 addresses for the other hostnames + // This simulates what `getaddrinfo` does when the family is not specified + recordTypes.push("A"); } (async () => { |
