2023-04-26 10:56:04 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
|
|
|
|
|
|
|
const assert = require('assert');
|
|
|
|
const dns = require('dns');
|
|
|
|
|
|
|
|
dns.setDefaultResultOrder('ipv4first');
|
|
|
|
let dnsOrder = dns.getDefaultResultOrder();
|
|
|
|
assert.ok(dnsOrder === 'ipv4first');
|
2024-04-17 17:24:28 +02:00
|
|
|
dns.setDefaultResultOrder('ipv6first');
|
|
|
|
dnsOrder = dns.getDefaultResultOrder();
|
|
|
|
assert.ok(dnsOrder === 'ipv6first');
|
2023-04-26 10:56:04 +02:00
|
|
|
dns.setDefaultResultOrder('verbatim');
|
|
|
|
dnsOrder = dns.getDefaultResultOrder();
|
|
|
|
assert.ok(dnsOrder === 'verbatim');
|
|
|
|
|
|
|
|
{
|
|
|
|
(async function() {
|
|
|
|
const result = await dns.promises.lookup('localhost');
|
2024-04-17 17:24:28 +02:00
|
|
|
const result1 = await dns.promises.lookup('localhost', { order: 'verbatim' });
|
2023-04-26 10:56:04 +02:00
|
|
|
assert.ok(result !== undefined);
|
|
|
|
assert.ok(result1 !== undefined);
|
|
|
|
assert.ok(result.address === result1.address);
|
|
|
|
assert.ok(result.family === result1.family);
|
|
|
|
})().then(common.mustCall());
|
|
|
|
}
|
2024-04-17 17:24:28 +02:00
|
|
|
|
|
|
|
{
|
|
|
|
(async function() {
|
|
|
|
const result = await dns.promises.lookup('localhost', { order: 'ipv4first' });
|
|
|
|
assert.ok(result !== undefined);
|
|
|
|
assert.ok(result.family === 4);
|
|
|
|
})().then(common.mustCall());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (common.hasIPv6) {
|
|
|
|
(async function() {
|
|
|
|
const result = await dns.promises.lookup('localhost', { order: 'ipv6first' });
|
|
|
|
assert.ok(result !== undefined);
|
|
|
|
assert.ok(result.family === 6);
|
|
|
|
})().then(common.mustCall());
|
|
|
|
}
|