From b4b6ddb7770baaca11b9b5dadfa095c642f77061 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 219934f00d84cd..a2564b903b44da 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 0c45728782d20a..12b666191b9ef5 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());