From 123982d11dee50a471f73a64462720eb36b75595 Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Thu, 17 Oct 2024 15:18:28 +0200 Subject: [PATCH] dns: honor the order option Fixes: https://github.com/nodejs/node/issues/55391 PR-URL: https://github.com/nodejs/node/pull/55392 Reviewed-By: Matteo Collina Reviewed-By: Tim Perry Reviewed-By: Richard Lau Reviewed-By: Yagiz Nizipli Reviewed-By: Feng Yu Reviewed-By: Jake Yuesong Li --- lib/dns.js | 2 +- test/parallel/test-dns-default-order-verbatim.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/dns.js b/lib/dns.js index 219934f00d8..a2564b903b4 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -193,7 +193,7 @@ function lookup(hostname, options, callback) { } if (options?.order != null) { validateOneOf(options.order, 'options.order', ['ipv4first', 'ipv6first', 'verbatim']); - dnsOrder = options.dnsOrder; + dnsOrder = options.order; } } diff --git a/test/parallel/test-dns-default-order-verbatim.js b/test/parallel/test-dns-default-order-verbatim.js index 0c45728782d..12b666191b9 100644 --- a/test/parallel/test-dns-default-order-verbatim.js +++ b/test/parallel/test-dns-default-order-verbatim.js @@ -46,4 +46,14 @@ function allowFailed(fn) { await allowFailed(dnsPromises.lookup('example.org', {})); checkParameter(cares.DNS_ORDER_VERBATIM); + + await allowFailed( + promisify(dns.lookup)('example.org', { order: 'ipv4first' }) + ); + checkParameter(cares.DNS_ORDER_IPV4_FIRST); + + await allowFailed( + promisify(dns.lookup)('example.org', { order: 'ipv6first' }) + ); + checkParameter(cares.DNS_ORDER_IPV6_FIRST); })().then(common.mustCall());