You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

isResolvable.js 425B

12345678910111213141516171819202122232425262728
  1. /**
  2. * Module dependencies.
  3. */
  4. var dns = require('dns');
  5. /**
  6. * Module exports.
  7. */
  8. module.exports = isResolvable;
  9. isResolvable.async = true;
  10. /**
  11. * Tries to resolve the hostname. Returns true if succeeds.
  12. *
  13. * @param {String} host is the hostname from the URL.
  14. * @return {Boolean}
  15. */
  16. function isResolvable (host, fn) {
  17. var family = 4;
  18. dns.lookup(host, family, function (err, ip) {
  19. fn(null, !err);
  20. });
  21. }