2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2010-12-04 15:20:34 -08:00
|
|
|
var common = require('../common');
|
|
|
|
var assert = require('assert');
|
2010-04-07 15:37:08 -07:00
|
|
|
|
2010-12-05 22:15:30 +03:00
|
|
|
var dns = require('dns');
|
2010-04-07 15:37:08 -07:00
|
|
|
|
|
|
|
|
|
|
|
// Try resolution without callback
|
|
|
|
|
2010-12-05 22:15:30 +03:00
|
|
|
dns.lookup(null, function(error, result, addressType) {
|
|
|
|
assert.equal(null, result);
|
|
|
|
assert.equal(4, addressType);
|
2010-04-07 15:37:08 -07:00
|
|
|
});
|
|
|
|
|
2010-12-05 22:15:30 +03:00
|
|
|
dns.lookup('127.0.0.1', function(error, result, addressType) {
|
|
|
|
assert.equal('127.0.0.1', result);
|
|
|
|
assert.equal(4, addressType);
|
2010-04-07 16:04:33 -07:00
|
|
|
});
|
|
|
|
|
2010-12-05 22:15:30 +03:00
|
|
|
dns.lookup('::1', function(error, result, addressType) {
|
|
|
|
assert.equal('::1', result);
|
|
|
|
assert.equal(6, addressType);
|
2010-04-07 16:04:33 -07:00
|
|
|
});
|
|
|
|
|
2013-03-03 12:53:51 +08:00
|
|
|
// Try calling resolve with an unsupported type.
|
|
|
|
assert.throws(function() {
|
|
|
|
dns.resolve('www.google.com', 'HI');
|
|
|
|
}, /Unknown type/);
|
|
|
|
|
2016-03-22 15:40:36 +02:00
|
|
|
// Try calling resolve with an unsupported type that's an object key
|
|
|
|
assert.throws(function() {
|
|
|
|
dns.resolve('www.google.com', 'toString');
|
|
|
|
}, /Unknown type/);
|
|
|
|
|
2011-10-18 16:12:07 -07:00
|
|
|
// Windows doesn't usually have an entry for localhost 127.0.0.1 in
|
|
|
|
// C:\Windows\System32\drivers\etc\hosts
|
|
|
|
// so we disable this test on Windows.
|
2015-07-29 17:18:04 +05:30
|
|
|
if (!common.isWindows) {
|
2016-02-08 10:57:24 +01:00
|
|
|
dns.reverse('127.0.0.1', function(error, domains) {
|
2011-10-18 16:12:07 -07:00
|
|
|
if (error) throw error;
|
|
|
|
assert.ok(Array.isArray(domains));
|
|
|
|
});
|
|
|
|
}
|