11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst {
31cb0ef41Sopenharmony_ci  ArrayPrototypeMap,
41cb0ef41Sopenharmony_ci  ObjectDefineProperty,
51cb0ef41Sopenharmony_ci  Promise,
61cb0ef41Sopenharmony_ci  ReflectApply,
71cb0ef41Sopenharmony_ci  Symbol,
81cb0ef41Sopenharmony_ci} = primordials;
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ciconst {
111cb0ef41Sopenharmony_ci  bindDefaultResolver,
121cb0ef41Sopenharmony_ci  createResolverClass,
131cb0ef41Sopenharmony_ci  validateHints,
141cb0ef41Sopenharmony_ci  emitInvalidHostnameWarning,
151cb0ef41Sopenharmony_ci  getDefaultVerbatim,
161cb0ef41Sopenharmony_ci  errorCodes: dnsErrorCodes,
171cb0ef41Sopenharmony_ci  getDefaultResultOrder,
181cb0ef41Sopenharmony_ci  setDefaultResultOrder,
191cb0ef41Sopenharmony_ci  setDefaultResolver,
201cb0ef41Sopenharmony_ci} = require('internal/dns/utils');
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ciconst {
231cb0ef41Sopenharmony_ci  NODATA,
241cb0ef41Sopenharmony_ci  FORMERR,
251cb0ef41Sopenharmony_ci  SERVFAIL,
261cb0ef41Sopenharmony_ci  NOTFOUND,
271cb0ef41Sopenharmony_ci  NOTIMP,
281cb0ef41Sopenharmony_ci  REFUSED,
291cb0ef41Sopenharmony_ci  BADQUERY,
301cb0ef41Sopenharmony_ci  BADNAME,
311cb0ef41Sopenharmony_ci  BADFAMILY,
321cb0ef41Sopenharmony_ci  BADRESP,
331cb0ef41Sopenharmony_ci  CONNREFUSED,
341cb0ef41Sopenharmony_ci  TIMEOUT,
351cb0ef41Sopenharmony_ci  EOF,
361cb0ef41Sopenharmony_ci  FILE,
371cb0ef41Sopenharmony_ci  NOMEM,
381cb0ef41Sopenharmony_ci  DESTRUCTION,
391cb0ef41Sopenharmony_ci  BADSTR,
401cb0ef41Sopenharmony_ci  BADFLAGS,
411cb0ef41Sopenharmony_ci  NONAME,
421cb0ef41Sopenharmony_ci  BADHINTS,
431cb0ef41Sopenharmony_ci  NOTINITIALIZED,
441cb0ef41Sopenharmony_ci  LOADIPHLPAPI,
451cb0ef41Sopenharmony_ci  ADDRGETNETWORKPARAMS,
461cb0ef41Sopenharmony_ci  CANCELLED,
471cb0ef41Sopenharmony_ci} = dnsErrorCodes;
481cb0ef41Sopenharmony_ciconst { codes, dnsException } = require('internal/errors');
491cb0ef41Sopenharmony_ciconst { isIP } = require('internal/net');
501cb0ef41Sopenharmony_ciconst {
511cb0ef41Sopenharmony_ci  getaddrinfo,
521cb0ef41Sopenharmony_ci  getnameinfo,
531cb0ef41Sopenharmony_ci  GetAddrInfoReqWrap,
541cb0ef41Sopenharmony_ci  GetNameInfoReqWrap,
551cb0ef41Sopenharmony_ci  QueryReqWrap,
561cb0ef41Sopenharmony_ci} = internalBinding('cares_wrap');
571cb0ef41Sopenharmony_ciconst {
581cb0ef41Sopenharmony_ci  ERR_INVALID_ARG_TYPE,
591cb0ef41Sopenharmony_ci  ERR_INVALID_ARG_VALUE,
601cb0ef41Sopenharmony_ci  ERR_MISSING_ARGS,
611cb0ef41Sopenharmony_ci} = codes;
621cb0ef41Sopenharmony_ciconst {
631cb0ef41Sopenharmony_ci  validateBoolean,
641cb0ef41Sopenharmony_ci  validateNumber,
651cb0ef41Sopenharmony_ci  validateOneOf,
661cb0ef41Sopenharmony_ci  validatePort,
671cb0ef41Sopenharmony_ci  validateString,
681cb0ef41Sopenharmony_ci} = require('internal/validators');
691cb0ef41Sopenharmony_ci
701cb0ef41Sopenharmony_ciconst kPerfHooksDnsLookupContext = Symbol('kPerfHooksDnsLookupContext');
711cb0ef41Sopenharmony_ciconst kPerfHooksDnsLookupServiceContext = Symbol('kPerfHooksDnsLookupServiceContext');
721cb0ef41Sopenharmony_ciconst kPerfHooksDnsLookupResolveContext = Symbol('kPerfHooksDnsLookupResolveContext');
731cb0ef41Sopenharmony_ci
741cb0ef41Sopenharmony_ciconst {
751cb0ef41Sopenharmony_ci  hasObserver,
761cb0ef41Sopenharmony_ci  startPerf,
771cb0ef41Sopenharmony_ci  stopPerf,
781cb0ef41Sopenharmony_ci} = require('internal/perf/observe');
791cb0ef41Sopenharmony_ci
801cb0ef41Sopenharmony_cifunction onlookup(err, addresses) {
811cb0ef41Sopenharmony_ci  if (err) {
821cb0ef41Sopenharmony_ci    this.reject(dnsException(err, 'getaddrinfo', this.hostname));
831cb0ef41Sopenharmony_ci    return;
841cb0ef41Sopenharmony_ci  }
851cb0ef41Sopenharmony_ci
861cb0ef41Sopenharmony_ci  const family = this.family || isIP(addresses[0]);
871cb0ef41Sopenharmony_ci  this.resolve({ address: addresses[0], family });
881cb0ef41Sopenharmony_ci  if (this[kPerfHooksDnsLookupContext] && hasObserver('dns')) {
891cb0ef41Sopenharmony_ci    stopPerf(this, kPerfHooksDnsLookupContext, { detail: { addresses } });
901cb0ef41Sopenharmony_ci  }
911cb0ef41Sopenharmony_ci}
921cb0ef41Sopenharmony_ci
931cb0ef41Sopenharmony_cifunction onlookupall(err, addresses) {
941cb0ef41Sopenharmony_ci  if (err) {
951cb0ef41Sopenharmony_ci    this.reject(dnsException(err, 'getaddrinfo', this.hostname));
961cb0ef41Sopenharmony_ci    return;
971cb0ef41Sopenharmony_ci  }
981cb0ef41Sopenharmony_ci
991cb0ef41Sopenharmony_ci  const family = this.family;
1001cb0ef41Sopenharmony_ci
1011cb0ef41Sopenharmony_ci  for (let i = 0; i < addresses.length; i++) {
1021cb0ef41Sopenharmony_ci    const address = addresses[i];
1031cb0ef41Sopenharmony_ci
1041cb0ef41Sopenharmony_ci    addresses[i] = {
1051cb0ef41Sopenharmony_ci      address,
1061cb0ef41Sopenharmony_ci      family: family || isIP(addresses[i]),
1071cb0ef41Sopenharmony_ci    };
1081cb0ef41Sopenharmony_ci  }
1091cb0ef41Sopenharmony_ci
1101cb0ef41Sopenharmony_ci  this.resolve(addresses);
1111cb0ef41Sopenharmony_ci  if (this[kPerfHooksDnsLookupContext] && hasObserver('dns')) {
1121cb0ef41Sopenharmony_ci    stopPerf(this, kPerfHooksDnsLookupContext, { detail: { addresses } });
1131cb0ef41Sopenharmony_ci  }
1141cb0ef41Sopenharmony_ci}
1151cb0ef41Sopenharmony_ci
1161cb0ef41Sopenharmony_ci/**
1171cb0ef41Sopenharmony_ci * Creates a promise that resolves with the IP address of the given hostname.
1181cb0ef41Sopenharmony_ci * @param {0 | 4 | 6} family - The IP address family (4 or 6, or 0 for both).
1191cb0ef41Sopenharmony_ci * @param {string} hostname - The hostname to resolve.
1201cb0ef41Sopenharmony_ci * @param {boolean} all - Whether to resolve with all IP addresses for the hostname.
1211cb0ef41Sopenharmony_ci * @param {number} hints - One or more supported getaddrinfo flags (supply multiple via
1221cb0ef41Sopenharmony_ci * bitwise OR).
1231cb0ef41Sopenharmony_ci * @param {boolean} verbatim - Whether to use the hostname verbatim.
1241cb0ef41Sopenharmony_ci * @returns {Promise<DNSLookupResult | DNSLookupResult[]>} The IP address(es) of the hostname.
1251cb0ef41Sopenharmony_ci * @typedef {object} DNSLookupResult
1261cb0ef41Sopenharmony_ci * @property {string} address - The IP address.
1271cb0ef41Sopenharmony_ci * @property {0 | 4 | 6} family - The IP address type. 4 for IPv4 or 6 for IPv6, or 0 (for both).
1281cb0ef41Sopenharmony_ci */
1291cb0ef41Sopenharmony_cifunction createLookupPromise(family, hostname, all, hints, verbatim) {
1301cb0ef41Sopenharmony_ci  return new Promise((resolve, reject) => {
1311cb0ef41Sopenharmony_ci    if (!hostname) {
1321cb0ef41Sopenharmony_ci      emitInvalidHostnameWarning(hostname);
1331cb0ef41Sopenharmony_ci      resolve(all ? [] : { address: null, family: family === 6 ? 6 : 4 });
1341cb0ef41Sopenharmony_ci      return;
1351cb0ef41Sopenharmony_ci    }
1361cb0ef41Sopenharmony_ci
1371cb0ef41Sopenharmony_ci    const matchedFamily = isIP(hostname);
1381cb0ef41Sopenharmony_ci
1391cb0ef41Sopenharmony_ci    if (matchedFamily !== 0) {
1401cb0ef41Sopenharmony_ci      const result = { address: hostname, family: matchedFamily };
1411cb0ef41Sopenharmony_ci      resolve(all ? [result] : result);
1421cb0ef41Sopenharmony_ci      return;
1431cb0ef41Sopenharmony_ci    }
1441cb0ef41Sopenharmony_ci
1451cb0ef41Sopenharmony_ci    const req = new GetAddrInfoReqWrap();
1461cb0ef41Sopenharmony_ci
1471cb0ef41Sopenharmony_ci    req.family = family;
1481cb0ef41Sopenharmony_ci    req.hostname = hostname;
1491cb0ef41Sopenharmony_ci    req.oncomplete = all ? onlookupall : onlookup;
1501cb0ef41Sopenharmony_ci    req.resolve = resolve;
1511cb0ef41Sopenharmony_ci    req.reject = reject;
1521cb0ef41Sopenharmony_ci
1531cb0ef41Sopenharmony_ci    const err = getaddrinfo(req, hostname, family, hints, verbatim);
1541cb0ef41Sopenharmony_ci
1551cb0ef41Sopenharmony_ci    if (err) {
1561cb0ef41Sopenharmony_ci      reject(dnsException(err, 'getaddrinfo', hostname));
1571cb0ef41Sopenharmony_ci    } else if (hasObserver('dns')) {
1581cb0ef41Sopenharmony_ci      const detail = {
1591cb0ef41Sopenharmony_ci        hostname,
1601cb0ef41Sopenharmony_ci        family,
1611cb0ef41Sopenharmony_ci        hints,
1621cb0ef41Sopenharmony_ci        verbatim,
1631cb0ef41Sopenharmony_ci      };
1641cb0ef41Sopenharmony_ci      startPerf(req, kPerfHooksDnsLookupContext, { type: 'dns', name: 'lookup', detail });
1651cb0ef41Sopenharmony_ci    }
1661cb0ef41Sopenharmony_ci  });
1671cb0ef41Sopenharmony_ci}
1681cb0ef41Sopenharmony_ci
1691cb0ef41Sopenharmony_ciconst validFamilies = [0, 4, 6];
1701cb0ef41Sopenharmony_ci/**
1711cb0ef41Sopenharmony_ci * Get the IP address for a given hostname.
1721cb0ef41Sopenharmony_ci * @param {string} hostname - The hostname to resolve (ex. 'nodejs.org').
1731cb0ef41Sopenharmony_ci * @param {object} [options] - Optional settings.
1741cb0ef41Sopenharmony_ci * @param {boolean} [options.all=false] - Whether to return all or just the first resolved address.
1751cb0ef41Sopenharmony_ci * @param {0 | 4 | 6} [options.family=0] - The record family. Must be 4, 6, or 0 (for both).
1761cb0ef41Sopenharmony_ci * @param {number} [options.hints] - One or more supported getaddrinfo flags (supply multiple via
1771cb0ef41Sopenharmony_ci * bitwise OR).
1781cb0ef41Sopenharmony_ci * @param {boolean} [options.verbatim=false] - Return results in same order DNS resolved them;
1791cb0ef41Sopenharmony_ci * otherwise IPv4 then IPv6. New code should supply `true`.
1801cb0ef41Sopenharmony_ci */
1811cb0ef41Sopenharmony_cifunction lookup(hostname, options) {
1821cb0ef41Sopenharmony_ci  let hints = 0;
1831cb0ef41Sopenharmony_ci  let family = 0;
1841cb0ef41Sopenharmony_ci  let all = false;
1851cb0ef41Sopenharmony_ci  let verbatim = getDefaultVerbatim();
1861cb0ef41Sopenharmony_ci
1871cb0ef41Sopenharmony_ci  // Parse arguments
1881cb0ef41Sopenharmony_ci  if (hostname) {
1891cb0ef41Sopenharmony_ci    validateString(hostname, 'hostname');
1901cb0ef41Sopenharmony_ci  }
1911cb0ef41Sopenharmony_ci
1921cb0ef41Sopenharmony_ci  if (typeof options === 'number') {
1931cb0ef41Sopenharmony_ci    validateOneOf(options, 'family', validFamilies);
1941cb0ef41Sopenharmony_ci    family = options;
1951cb0ef41Sopenharmony_ci  } else if (options !== undefined && typeof options !== 'object') {
1961cb0ef41Sopenharmony_ci    throw new ERR_INVALID_ARG_TYPE('options', ['integer', 'object'], options);
1971cb0ef41Sopenharmony_ci  } else {
1981cb0ef41Sopenharmony_ci    if (options?.hints != null) {
1991cb0ef41Sopenharmony_ci      validateNumber(options.hints, 'options.hints');
2001cb0ef41Sopenharmony_ci      hints = options.hints >>> 0;
2011cb0ef41Sopenharmony_ci      validateHints(hints);
2021cb0ef41Sopenharmony_ci    }
2031cb0ef41Sopenharmony_ci    if (options?.family != null) {
2041cb0ef41Sopenharmony_ci      validateOneOf(options.family, 'options.family', validFamilies);
2051cb0ef41Sopenharmony_ci      family = options.family;
2061cb0ef41Sopenharmony_ci    }
2071cb0ef41Sopenharmony_ci    if (options?.all != null) {
2081cb0ef41Sopenharmony_ci      validateBoolean(options.all, 'options.all');
2091cb0ef41Sopenharmony_ci      all = options.all;
2101cb0ef41Sopenharmony_ci    }
2111cb0ef41Sopenharmony_ci    if (options?.verbatim != null) {
2121cb0ef41Sopenharmony_ci      validateBoolean(options.verbatim, 'options.verbatim');
2131cb0ef41Sopenharmony_ci      verbatim = options.verbatim;
2141cb0ef41Sopenharmony_ci    }
2151cb0ef41Sopenharmony_ci  }
2161cb0ef41Sopenharmony_ci
2171cb0ef41Sopenharmony_ci  return createLookupPromise(family, hostname, all, hints, verbatim);
2181cb0ef41Sopenharmony_ci}
2191cb0ef41Sopenharmony_ci
2201cb0ef41Sopenharmony_ci
2211cb0ef41Sopenharmony_cifunction onlookupservice(err, hostname, service) {
2221cb0ef41Sopenharmony_ci  if (err) {
2231cb0ef41Sopenharmony_ci    this.reject(dnsException(err, 'getnameinfo', this.host));
2241cb0ef41Sopenharmony_ci    return;
2251cb0ef41Sopenharmony_ci  }
2261cb0ef41Sopenharmony_ci
2271cb0ef41Sopenharmony_ci  this.resolve({ hostname, service });
2281cb0ef41Sopenharmony_ci  if (this[kPerfHooksDnsLookupServiceContext] && hasObserver('dns')) {
2291cb0ef41Sopenharmony_ci    stopPerf(this, kPerfHooksDnsLookupServiceContext, { detail: { hostname, service } });
2301cb0ef41Sopenharmony_ci  }
2311cb0ef41Sopenharmony_ci}
2321cb0ef41Sopenharmony_ci
2331cb0ef41Sopenharmony_cifunction createLookupServicePromise(hostname, port) {
2341cb0ef41Sopenharmony_ci  return new Promise((resolve, reject) => {
2351cb0ef41Sopenharmony_ci    const req = new GetNameInfoReqWrap();
2361cb0ef41Sopenharmony_ci
2371cb0ef41Sopenharmony_ci    req.hostname = hostname;
2381cb0ef41Sopenharmony_ci    req.port = port;
2391cb0ef41Sopenharmony_ci    req.oncomplete = onlookupservice;
2401cb0ef41Sopenharmony_ci    req.resolve = resolve;
2411cb0ef41Sopenharmony_ci    req.reject = reject;
2421cb0ef41Sopenharmony_ci
2431cb0ef41Sopenharmony_ci    const err = getnameinfo(req, hostname, port);
2441cb0ef41Sopenharmony_ci
2451cb0ef41Sopenharmony_ci    if (err)
2461cb0ef41Sopenharmony_ci      reject(dnsException(err, 'getnameinfo', hostname));
2471cb0ef41Sopenharmony_ci    else if (hasObserver('dns')) {
2481cb0ef41Sopenharmony_ci      startPerf(req, kPerfHooksDnsLookupServiceContext, {
2491cb0ef41Sopenharmony_ci        type: 'dns',
2501cb0ef41Sopenharmony_ci        name: 'lookupService',
2511cb0ef41Sopenharmony_ci        detail: {
2521cb0ef41Sopenharmony_ci          host: hostname,
2531cb0ef41Sopenharmony_ci          port,
2541cb0ef41Sopenharmony_ci        },
2551cb0ef41Sopenharmony_ci      });
2561cb0ef41Sopenharmony_ci    }
2571cb0ef41Sopenharmony_ci  });
2581cb0ef41Sopenharmony_ci}
2591cb0ef41Sopenharmony_ci
2601cb0ef41Sopenharmony_cifunction lookupService(address, port) {
2611cb0ef41Sopenharmony_ci  if (arguments.length !== 2)
2621cb0ef41Sopenharmony_ci    throw new ERR_MISSING_ARGS('address', 'port');
2631cb0ef41Sopenharmony_ci
2641cb0ef41Sopenharmony_ci  if (isIP(address) === 0)
2651cb0ef41Sopenharmony_ci    throw new ERR_INVALID_ARG_VALUE('address', address);
2661cb0ef41Sopenharmony_ci
2671cb0ef41Sopenharmony_ci  validatePort(port);
2681cb0ef41Sopenharmony_ci
2691cb0ef41Sopenharmony_ci  return createLookupServicePromise(address, +port);
2701cb0ef41Sopenharmony_ci}
2711cb0ef41Sopenharmony_ci
2721cb0ef41Sopenharmony_ci
2731cb0ef41Sopenharmony_cifunction onresolve(err, result, ttls) {
2741cb0ef41Sopenharmony_ci  if (err) {
2751cb0ef41Sopenharmony_ci    this.reject(dnsException(err, this.bindingName, this.hostname));
2761cb0ef41Sopenharmony_ci    return;
2771cb0ef41Sopenharmony_ci  }
2781cb0ef41Sopenharmony_ci
2791cb0ef41Sopenharmony_ci  if (ttls && this.ttl)
2801cb0ef41Sopenharmony_ci    result = ArrayPrototypeMap(
2811cb0ef41Sopenharmony_ci      result, (address, index) => ({ address, ttl: ttls[index] }));
2821cb0ef41Sopenharmony_ci
2831cb0ef41Sopenharmony_ci  this.resolve(result);
2841cb0ef41Sopenharmony_ci  if (this[kPerfHooksDnsLookupResolveContext] && hasObserver('dns')) {
2851cb0ef41Sopenharmony_ci    stopPerf(this, kPerfHooksDnsLookupResolveContext, { detail: { result } });
2861cb0ef41Sopenharmony_ci  }
2871cb0ef41Sopenharmony_ci}
2881cb0ef41Sopenharmony_ci
2891cb0ef41Sopenharmony_cifunction createResolverPromise(resolver, bindingName, hostname, ttl) {
2901cb0ef41Sopenharmony_ci  return new Promise((resolve, reject) => {
2911cb0ef41Sopenharmony_ci    const req = new QueryReqWrap();
2921cb0ef41Sopenharmony_ci
2931cb0ef41Sopenharmony_ci    req.bindingName = bindingName;
2941cb0ef41Sopenharmony_ci    req.hostname = hostname;
2951cb0ef41Sopenharmony_ci    req.oncomplete = onresolve;
2961cb0ef41Sopenharmony_ci    req.resolve = resolve;
2971cb0ef41Sopenharmony_ci    req.reject = reject;
2981cb0ef41Sopenharmony_ci    req.ttl = ttl;
2991cb0ef41Sopenharmony_ci
3001cb0ef41Sopenharmony_ci    const err = resolver._handle[bindingName](req, hostname);
3011cb0ef41Sopenharmony_ci
3021cb0ef41Sopenharmony_ci    if (err)
3031cb0ef41Sopenharmony_ci      reject(dnsException(err, bindingName, hostname));
3041cb0ef41Sopenharmony_ci    else if (hasObserver('dns')) {
3051cb0ef41Sopenharmony_ci      startPerf(req, kPerfHooksDnsLookupResolveContext, {
3061cb0ef41Sopenharmony_ci        type: 'dns',
3071cb0ef41Sopenharmony_ci        name: bindingName,
3081cb0ef41Sopenharmony_ci        detail: {
3091cb0ef41Sopenharmony_ci          host: hostname,
3101cb0ef41Sopenharmony_ci          ttl,
3111cb0ef41Sopenharmony_ci        },
3121cb0ef41Sopenharmony_ci      });
3131cb0ef41Sopenharmony_ci    }
3141cb0ef41Sopenharmony_ci  });
3151cb0ef41Sopenharmony_ci}
3161cb0ef41Sopenharmony_ci
3171cb0ef41Sopenharmony_cifunction resolver(bindingName) {
3181cb0ef41Sopenharmony_ci  function query(name, options) {
3191cb0ef41Sopenharmony_ci    validateString(name, 'name');
3201cb0ef41Sopenharmony_ci
3211cb0ef41Sopenharmony_ci    const ttl = !!(options && options.ttl);
3221cb0ef41Sopenharmony_ci    return createResolverPromise(this, bindingName, name, ttl);
3231cb0ef41Sopenharmony_ci  }
3241cb0ef41Sopenharmony_ci
3251cb0ef41Sopenharmony_ci  ObjectDefineProperty(query, 'name', { __proto__: null, value: bindingName });
3261cb0ef41Sopenharmony_ci  return query;
3271cb0ef41Sopenharmony_ci}
3281cb0ef41Sopenharmony_ci
3291cb0ef41Sopenharmony_cifunction resolve(hostname, rrtype) {
3301cb0ef41Sopenharmony_ci  let resolver;
3311cb0ef41Sopenharmony_ci
3321cb0ef41Sopenharmony_ci  if (rrtype !== undefined) {
3331cb0ef41Sopenharmony_ci    validateString(rrtype, 'rrtype');
3341cb0ef41Sopenharmony_ci
3351cb0ef41Sopenharmony_ci    resolver = resolveMap[rrtype];
3361cb0ef41Sopenharmony_ci
3371cb0ef41Sopenharmony_ci    if (typeof resolver !== 'function')
3381cb0ef41Sopenharmony_ci      throw new ERR_INVALID_ARG_VALUE('rrtype', rrtype);
3391cb0ef41Sopenharmony_ci  } else {
3401cb0ef41Sopenharmony_ci    resolver = resolveMap.A;
3411cb0ef41Sopenharmony_ci  }
3421cb0ef41Sopenharmony_ci
3431cb0ef41Sopenharmony_ci  return ReflectApply(resolver, this, [hostname]);
3441cb0ef41Sopenharmony_ci}
3451cb0ef41Sopenharmony_ci
3461cb0ef41Sopenharmony_ci// Promise-based resolver.
3471cb0ef41Sopenharmony_ciconst { Resolver, resolveMap } = createResolverClass(resolver);
3481cb0ef41Sopenharmony_ciResolver.prototype.resolve = resolve;
3491cb0ef41Sopenharmony_ci
3501cb0ef41Sopenharmony_cifunction defaultResolverSetServers(servers) {
3511cb0ef41Sopenharmony_ci  const resolver = new Resolver();
3521cb0ef41Sopenharmony_ci
3531cb0ef41Sopenharmony_ci  resolver.setServers(servers);
3541cb0ef41Sopenharmony_ci  setDefaultResolver(resolver);
3551cb0ef41Sopenharmony_ci  bindDefaultResolver(module.exports, Resolver.prototype);
3561cb0ef41Sopenharmony_ci}
3571cb0ef41Sopenharmony_ci
3581cb0ef41Sopenharmony_cimodule.exports = {
3591cb0ef41Sopenharmony_ci  lookup,
3601cb0ef41Sopenharmony_ci  lookupService,
3611cb0ef41Sopenharmony_ci  Resolver,
3621cb0ef41Sopenharmony_ci  getDefaultResultOrder,
3631cb0ef41Sopenharmony_ci  setDefaultResultOrder,
3641cb0ef41Sopenharmony_ci  setServers: defaultResolverSetServers,
3651cb0ef41Sopenharmony_ci
3661cb0ef41Sopenharmony_ci  // ERROR CODES
3671cb0ef41Sopenharmony_ci  NODATA,
3681cb0ef41Sopenharmony_ci  FORMERR,
3691cb0ef41Sopenharmony_ci  SERVFAIL,
3701cb0ef41Sopenharmony_ci  NOTFOUND,
3711cb0ef41Sopenharmony_ci  NOTIMP,
3721cb0ef41Sopenharmony_ci  REFUSED,
3731cb0ef41Sopenharmony_ci  BADQUERY,
3741cb0ef41Sopenharmony_ci  BADNAME,
3751cb0ef41Sopenharmony_ci  BADFAMILY,
3761cb0ef41Sopenharmony_ci  BADRESP,
3771cb0ef41Sopenharmony_ci  CONNREFUSED,
3781cb0ef41Sopenharmony_ci  TIMEOUT,
3791cb0ef41Sopenharmony_ci  EOF,
3801cb0ef41Sopenharmony_ci  FILE,
3811cb0ef41Sopenharmony_ci  NOMEM,
3821cb0ef41Sopenharmony_ci  DESTRUCTION,
3831cb0ef41Sopenharmony_ci  BADSTR,
3841cb0ef41Sopenharmony_ci  BADFLAGS,
3851cb0ef41Sopenharmony_ci  NONAME,
3861cb0ef41Sopenharmony_ci  BADHINTS,
3871cb0ef41Sopenharmony_ci  NOTINITIALIZED,
3881cb0ef41Sopenharmony_ci  LOADIPHLPAPI,
3891cb0ef41Sopenharmony_ci  ADDRGETNETWORKPARAMS,
3901cb0ef41Sopenharmony_ci  CANCELLED,
3911cb0ef41Sopenharmony_ci};
3921cb0ef41Sopenharmony_cibindDefaultResolver(module.exports, Resolver.prototype);
393