net: add dns.

This commit is contained in:
Christopher Jeffrey 2016-12-16 17:18:55 -08:00
parent af8194112e
commit 2c2ad461af
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 38 additions and 0 deletions

11
lib/net/dns-browser.js Normal file
View File

@ -0,0 +1,11 @@
/*!
* dns.js - dns backend for bcoin
* Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
exports.resolve = function resolve(host) {
return Promise.reject(new Error('No DNS results.'));
};

27
lib/net/dns.js Normal file
View File

@ -0,0 +1,27 @@
/*!
* dns.js - dns backend for bcoin
* Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
var dns = require('dns');
exports.resolve = function resolve(host) {
return new Promise(function(resolve, reject) {
dns.resolve(host, 'A', function(err, result) {
if (err) {
reject(err);
return;
}
if (result.length === 0) {
reject(new Error('No DNS results.'));
return;
}
resolve(result);
});
});
};