dnsResolve.js 770 B

1234567891011121314151617181920212223242526272829303132
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. const util_1 = require("./util");
  4. /**
  5. * Resolves the given DNS hostname into an IP address, and returns it in the dot
  6. * separated format as a string.
  7. *
  8. * Example:
  9. *
  10. * ``` js
  11. * dnsResolve("home.netscape.com")
  12. * // returns the string "198.95.249.79".
  13. * ```
  14. *
  15. * @param {String} host hostname to resolve
  16. * @return {String} resolved IP address
  17. */
  18. async function dnsResolve(host) {
  19. const family = 4;
  20. try {
  21. const r = await (0, util_1.dnsLookup)(host, { family });
  22. if (typeof r === 'string') {
  23. return r;
  24. }
  25. }
  26. catch (err) {
  27. // @ignore
  28. }
  29. return null;
  30. }
  31. exports.default = dnsResolve;
  32. //# sourceMappingURL=dnsResolve.js.map