Skip to content

Commit

Permalink
dns: honor the order option
Browse files Browse the repository at this point in the history
Fixes: #55391
PR-URL: #55392
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Feng Yu <F3n67u@outlook.com>
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
  • Loading branch information
lpinca authored and aduh95 committed Oct 19, 2024
1 parent f48d30e commit b4b6ddb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
10 changes: 10 additions & 0 deletions test/parallel/test-dns-default-order-verbatim.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());

0 comments on commit b4b6ddb

Please sign in to comment.