11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst {
41cb0ef41Sopenharmony_ci  ArrayPrototypeForEach,
51cb0ef41Sopenharmony_ci  ArrayPrototypeJoin,
61cb0ef41Sopenharmony_ci  ArrayPrototypeMap,
71cb0ef41Sopenharmony_ci  ArrayPrototypePush,
81cb0ef41Sopenharmony_ci  FunctionPrototypeBind,
91cb0ef41Sopenharmony_ci  NumberParseInt,
101cb0ef41Sopenharmony_ci  RegExpPrototypeExec,
111cb0ef41Sopenharmony_ci  RegExpPrototypeSymbolReplace,
121cb0ef41Sopenharmony_ci  ObjectCreate,
131cb0ef41Sopenharmony_ci  Symbol,
141cb0ef41Sopenharmony_ci} = primordials;
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ciconst errors = require('internal/errors');
171cb0ef41Sopenharmony_ciconst { isIP } = require('internal/net');
181cb0ef41Sopenharmony_ciconst { getOptionValue } = require('internal/options');
191cb0ef41Sopenharmony_ciconst {
201cb0ef41Sopenharmony_ci  validateArray,
211cb0ef41Sopenharmony_ci  validateInt32,
221cb0ef41Sopenharmony_ci  validateOneOf,
231cb0ef41Sopenharmony_ci  validateString,
241cb0ef41Sopenharmony_ci} = require('internal/validators');
251cb0ef41Sopenharmony_cilet binding;
261cb0ef41Sopenharmony_cifunction lazyBinding() {
271cb0ef41Sopenharmony_ci  binding ??= internalBinding('cares_wrap');
281cb0ef41Sopenharmony_ci  return binding;
291cb0ef41Sopenharmony_ci}
301cb0ef41Sopenharmony_ciconst IANA_DNS_PORT = 53;
311cb0ef41Sopenharmony_ciconst IPv6RE = /^\[([^[\]]*)\]/;
321cb0ef41Sopenharmony_ciconst addrSplitRE = /(^.+?)(?::(\d+))?$/;
331cb0ef41Sopenharmony_ciconst {
341cb0ef41Sopenharmony_ci  ERR_DNS_SET_SERVERS_FAILED,
351cb0ef41Sopenharmony_ci  ERR_INVALID_ARG_VALUE,
361cb0ef41Sopenharmony_ci  ERR_INVALID_IP_ADDRESS,
371cb0ef41Sopenharmony_ci} = errors.codes;
381cb0ef41Sopenharmony_ci
391cb0ef41Sopenharmony_ciconst {
401cb0ef41Sopenharmony_ci  namespace: {
411cb0ef41Sopenharmony_ci    addSerializeCallback,
421cb0ef41Sopenharmony_ci    addDeserializeCallback,
431cb0ef41Sopenharmony_ci    isBuildingSnapshot,
441cb0ef41Sopenharmony_ci  },
451cb0ef41Sopenharmony_ci} = require('internal/v8/startup_snapshot');
461cb0ef41Sopenharmony_ci
471cb0ef41Sopenharmony_cifunction validateTimeout(options) {
481cb0ef41Sopenharmony_ci  const { timeout = -1 } = { ...options };
491cb0ef41Sopenharmony_ci  validateInt32(timeout, 'options.timeout', -1);
501cb0ef41Sopenharmony_ci  return timeout;
511cb0ef41Sopenharmony_ci}
521cb0ef41Sopenharmony_ci
531cb0ef41Sopenharmony_cifunction validateTries(options) {
541cb0ef41Sopenharmony_ci  const { tries = 4 } = { ...options };
551cb0ef41Sopenharmony_ci  validateInt32(tries, 'options.tries', 1);
561cb0ef41Sopenharmony_ci  return tries;
571cb0ef41Sopenharmony_ci}
581cb0ef41Sopenharmony_ci
591cb0ef41Sopenharmony_ciconst kSerializeResolver = Symbol('dns:resolver:serialize');
601cb0ef41Sopenharmony_ciconst kDeserializeResolver = Symbol('dns:resolver:deserialize');
611cb0ef41Sopenharmony_ciconst kSnapshotStates = Symbol('dns:resolver:config');
621cb0ef41Sopenharmony_ciconst kInitializeHandle = Symbol('dns:resolver:initializeHandle');
631cb0ef41Sopenharmony_ciconst kSetServersInteral = Symbol('dns:resolver:setServers');
641cb0ef41Sopenharmony_ci
651cb0ef41Sopenharmony_ci// Resolver instances correspond 1:1 to c-ares channels.
661cb0ef41Sopenharmony_ci
671cb0ef41Sopenharmony_ciclass ResolverBase {
681cb0ef41Sopenharmony_ci  constructor(options = undefined) {
691cb0ef41Sopenharmony_ci    const timeout = validateTimeout(options);
701cb0ef41Sopenharmony_ci    const tries = validateTries(options);
711cb0ef41Sopenharmony_ci    // If we are building snapshot, save the states of the resolver along
721cb0ef41Sopenharmony_ci    // the way.
731cb0ef41Sopenharmony_ci    if (isBuildingSnapshot()) {
741cb0ef41Sopenharmony_ci      this[kSnapshotStates] = { timeout, tries };
751cb0ef41Sopenharmony_ci    }
761cb0ef41Sopenharmony_ci    this[kInitializeHandle](timeout, tries);
771cb0ef41Sopenharmony_ci  }
781cb0ef41Sopenharmony_ci
791cb0ef41Sopenharmony_ci  [kInitializeHandle](timeout, tries) {
801cb0ef41Sopenharmony_ci    const { ChannelWrap } = lazyBinding();
811cb0ef41Sopenharmony_ci    this._handle = new ChannelWrap(timeout, tries);
821cb0ef41Sopenharmony_ci  }
831cb0ef41Sopenharmony_ci
841cb0ef41Sopenharmony_ci  cancel() {
851cb0ef41Sopenharmony_ci    this._handle.cancel();
861cb0ef41Sopenharmony_ci  }
871cb0ef41Sopenharmony_ci
881cb0ef41Sopenharmony_ci  getServers() {
891cb0ef41Sopenharmony_ci    return ArrayPrototypeMap(this._handle.getServers() || [], (val) => {
901cb0ef41Sopenharmony_ci      if (!val[1] || val[1] === IANA_DNS_PORT)
911cb0ef41Sopenharmony_ci        return val[0];
921cb0ef41Sopenharmony_ci
931cb0ef41Sopenharmony_ci      const host = isIP(val[0]) === 6 ? `[${val[0]}]` : val[0];
941cb0ef41Sopenharmony_ci      return `${host}:${val[1]}`;
951cb0ef41Sopenharmony_ci    });
961cb0ef41Sopenharmony_ci  }
971cb0ef41Sopenharmony_ci
981cb0ef41Sopenharmony_ci  setServers(servers) {
991cb0ef41Sopenharmony_ci    validateArray(servers, 'servers');
1001cb0ef41Sopenharmony_ci
1011cb0ef41Sopenharmony_ci    // Cache the original servers because in the event of an error while
1021cb0ef41Sopenharmony_ci    // setting the servers, c-ares won't have any servers available for
1031cb0ef41Sopenharmony_ci    // resolution.
1041cb0ef41Sopenharmony_ci    const newSet = [];
1051cb0ef41Sopenharmony_ci    ArrayPrototypeForEach(servers, (serv, index) => {
1061cb0ef41Sopenharmony_ci      validateString(serv, `servers[${index}]`);
1071cb0ef41Sopenharmony_ci      let ipVersion = isIP(serv);
1081cb0ef41Sopenharmony_ci
1091cb0ef41Sopenharmony_ci      if (ipVersion !== 0)
1101cb0ef41Sopenharmony_ci        return ArrayPrototypePush(newSet, [ipVersion, serv, IANA_DNS_PORT]);
1111cb0ef41Sopenharmony_ci
1121cb0ef41Sopenharmony_ci      const match = RegExpPrototypeExec(IPv6RE, serv);
1131cb0ef41Sopenharmony_ci
1141cb0ef41Sopenharmony_ci      // Check for an IPv6 in brackets.
1151cb0ef41Sopenharmony_ci      if (match) {
1161cb0ef41Sopenharmony_ci        ipVersion = isIP(match[1]);
1171cb0ef41Sopenharmony_ci
1181cb0ef41Sopenharmony_ci        if (ipVersion !== 0) {
1191cb0ef41Sopenharmony_ci          const port = NumberParseInt(
1201cb0ef41Sopenharmony_ci            RegExpPrototypeSymbolReplace(addrSplitRE, serv, '$2')) || IANA_DNS_PORT;
1211cb0ef41Sopenharmony_ci          return ArrayPrototypePush(newSet, [ipVersion, match[1], port]);
1221cb0ef41Sopenharmony_ci        }
1231cb0ef41Sopenharmony_ci      }
1241cb0ef41Sopenharmony_ci
1251cb0ef41Sopenharmony_ci      // addr::port
1261cb0ef41Sopenharmony_ci      const addrSplitMatch = RegExpPrototypeExec(addrSplitRE, serv);
1271cb0ef41Sopenharmony_ci
1281cb0ef41Sopenharmony_ci      if (addrSplitMatch) {
1291cb0ef41Sopenharmony_ci        const hostIP = addrSplitMatch[1];
1301cb0ef41Sopenharmony_ci        const port = addrSplitMatch[2] || IANA_DNS_PORT;
1311cb0ef41Sopenharmony_ci
1321cb0ef41Sopenharmony_ci        ipVersion = isIP(hostIP);
1331cb0ef41Sopenharmony_ci
1341cb0ef41Sopenharmony_ci        if (ipVersion !== 0) {
1351cb0ef41Sopenharmony_ci          return ArrayPrototypePush(
1361cb0ef41Sopenharmony_ci            newSet, [ipVersion, hostIP, NumberParseInt(port)]);
1371cb0ef41Sopenharmony_ci        }
1381cb0ef41Sopenharmony_ci      }
1391cb0ef41Sopenharmony_ci
1401cb0ef41Sopenharmony_ci      throw new ERR_INVALID_IP_ADDRESS(serv);
1411cb0ef41Sopenharmony_ci    });
1421cb0ef41Sopenharmony_ci
1431cb0ef41Sopenharmony_ci    this[kSetServersInteral](newSet, servers);
1441cb0ef41Sopenharmony_ci  }
1451cb0ef41Sopenharmony_ci
1461cb0ef41Sopenharmony_ci  [kSetServersInteral](newSet, servers) {
1471cb0ef41Sopenharmony_ci    const orig = this._handle.getServers() || [];
1481cb0ef41Sopenharmony_ci    const errorNumber = this._handle.setServers(newSet);
1491cb0ef41Sopenharmony_ci
1501cb0ef41Sopenharmony_ci    if (errorNumber !== 0) {
1511cb0ef41Sopenharmony_ci      // Reset the servers to the old servers, because ares probably unset them.
1521cb0ef41Sopenharmony_ci      this._handle.setServers(ArrayPrototypeJoin(orig, ','));
1531cb0ef41Sopenharmony_ci      const { strerror } = lazyBinding();
1541cb0ef41Sopenharmony_ci      const err = strerror(errorNumber);
1551cb0ef41Sopenharmony_ci      throw new ERR_DNS_SET_SERVERS_FAILED(err, servers);
1561cb0ef41Sopenharmony_ci    }
1571cb0ef41Sopenharmony_ci
1581cb0ef41Sopenharmony_ci    if (isBuildingSnapshot()) {
1591cb0ef41Sopenharmony_ci      this[kSnapshotStates].servers = newSet;
1601cb0ef41Sopenharmony_ci    }
1611cb0ef41Sopenharmony_ci  }
1621cb0ef41Sopenharmony_ci
1631cb0ef41Sopenharmony_ci
1641cb0ef41Sopenharmony_ci  setLocalAddress(ipv4, ipv6) {
1651cb0ef41Sopenharmony_ci    validateString(ipv4, 'ipv4');
1661cb0ef41Sopenharmony_ci
1671cb0ef41Sopenharmony_ci    if (ipv6 !== undefined) {
1681cb0ef41Sopenharmony_ci      validateString(ipv6, 'ipv6');
1691cb0ef41Sopenharmony_ci    }
1701cb0ef41Sopenharmony_ci
1711cb0ef41Sopenharmony_ci    this._handle.setLocalAddress(ipv4, ipv6);
1721cb0ef41Sopenharmony_ci
1731cb0ef41Sopenharmony_ci    if (isBuildingSnapshot()) {
1741cb0ef41Sopenharmony_ci      this[kSnapshotStates].localAddress = { ipv4, ipv6 };
1751cb0ef41Sopenharmony_ci    }
1761cb0ef41Sopenharmony_ci  }
1771cb0ef41Sopenharmony_ci
1781cb0ef41Sopenharmony_ci  // TODO(joyeecheung): consider exposing this if custom DNS resolvers
1791cb0ef41Sopenharmony_ci  // end up being useful for snapshot users.
1801cb0ef41Sopenharmony_ci  [kSerializeResolver]() {
1811cb0ef41Sopenharmony_ci    this._handle = null;  // We'll restore it during deserialization.
1821cb0ef41Sopenharmony_ci    addDeserializeCallback(function deserializeResolver(resolver) {
1831cb0ef41Sopenharmony_ci      resolver[kDeserializeResolver]();
1841cb0ef41Sopenharmony_ci    }, this);
1851cb0ef41Sopenharmony_ci  }
1861cb0ef41Sopenharmony_ci
1871cb0ef41Sopenharmony_ci  [kDeserializeResolver]() {
1881cb0ef41Sopenharmony_ci    const { timeout, tries, localAddress, servers } = this[kSnapshotStates];
1891cb0ef41Sopenharmony_ci    this[kInitializeHandle](timeout, tries);
1901cb0ef41Sopenharmony_ci    if (localAddress) {
1911cb0ef41Sopenharmony_ci      const { ipv4, ipv6 } = localAddress;
1921cb0ef41Sopenharmony_ci      this._handle.setLocalAddress(ipv4, ipv6);
1931cb0ef41Sopenharmony_ci    }
1941cb0ef41Sopenharmony_ci    if (servers) {
1951cb0ef41Sopenharmony_ci      this[kSetServersInteral](servers, servers);
1961cb0ef41Sopenharmony_ci    }
1971cb0ef41Sopenharmony_ci  }
1981cb0ef41Sopenharmony_ci}
1991cb0ef41Sopenharmony_ci
2001cb0ef41Sopenharmony_cilet defaultResolver;
2011cb0ef41Sopenharmony_cilet dnsOrder;
2021cb0ef41Sopenharmony_ci
2031cb0ef41Sopenharmony_cifunction initializeDns() {
2041cb0ef41Sopenharmony_ci  const orderFromCLI = getOptionValue('--dns-result-order');
2051cb0ef41Sopenharmony_ci  if (!orderFromCLI) {
2061cb0ef41Sopenharmony_ci    dnsOrder ??= 'verbatim';
2071cb0ef41Sopenharmony_ci  } else {
2081cb0ef41Sopenharmony_ci    // Allow the deserialized application to override order from CLI.
2091cb0ef41Sopenharmony_ci    dnsOrder = orderFromCLI;
2101cb0ef41Sopenharmony_ci  }
2111cb0ef41Sopenharmony_ci
2121cb0ef41Sopenharmony_ci  if (!isBuildingSnapshot()) {
2131cb0ef41Sopenharmony_ci    return;
2141cb0ef41Sopenharmony_ci  }
2151cb0ef41Sopenharmony_ci
2161cb0ef41Sopenharmony_ci  addSerializeCallback(() => {
2171cb0ef41Sopenharmony_ci    defaultResolver?.[kSerializeResolver]();
2181cb0ef41Sopenharmony_ci  });
2191cb0ef41Sopenharmony_ci}
2201cb0ef41Sopenharmony_ci
2211cb0ef41Sopenharmony_ciconst resolverKeys = [
2221cb0ef41Sopenharmony_ci  'getServers',
2231cb0ef41Sopenharmony_ci  'resolve',
2241cb0ef41Sopenharmony_ci  'resolve4',
2251cb0ef41Sopenharmony_ci  'resolve6',
2261cb0ef41Sopenharmony_ci  'resolveAny',
2271cb0ef41Sopenharmony_ci  'resolveCaa',
2281cb0ef41Sopenharmony_ci  'resolveCname',
2291cb0ef41Sopenharmony_ci  'resolveMx',
2301cb0ef41Sopenharmony_ci  'resolveNaptr',
2311cb0ef41Sopenharmony_ci  'resolveNs',
2321cb0ef41Sopenharmony_ci  'resolvePtr',
2331cb0ef41Sopenharmony_ci  'resolveSoa',
2341cb0ef41Sopenharmony_ci  'resolveSrv',
2351cb0ef41Sopenharmony_ci  'resolveTxt',
2361cb0ef41Sopenharmony_ci  'reverse',
2371cb0ef41Sopenharmony_ci];
2381cb0ef41Sopenharmony_ci
2391cb0ef41Sopenharmony_cifunction getDefaultResolver() {
2401cb0ef41Sopenharmony_ci  // We do this here instead of pre-execution so that the default resolver is
2411cb0ef41Sopenharmony_ci  // only ever created when the user loads any dns module.
2421cb0ef41Sopenharmony_ci  if (defaultResolver === undefined) {
2431cb0ef41Sopenharmony_ci    defaultResolver = new ResolverBase();
2441cb0ef41Sopenharmony_ci  }
2451cb0ef41Sopenharmony_ci  return defaultResolver;
2461cb0ef41Sopenharmony_ci}
2471cb0ef41Sopenharmony_ci
2481cb0ef41Sopenharmony_cifunction setDefaultResolver(resolver) {
2491cb0ef41Sopenharmony_ci  defaultResolver = resolver;
2501cb0ef41Sopenharmony_ci}
2511cb0ef41Sopenharmony_ci
2521cb0ef41Sopenharmony_cifunction bindDefaultResolver(target, source) {
2531cb0ef41Sopenharmony_ci  const defaultResolver = getDefaultResolver();
2541cb0ef41Sopenharmony_ci  ArrayPrototypeForEach(resolverKeys, (key) => {
2551cb0ef41Sopenharmony_ci    target[key] = FunctionPrototypeBind(source[key], defaultResolver);
2561cb0ef41Sopenharmony_ci  });
2571cb0ef41Sopenharmony_ci}
2581cb0ef41Sopenharmony_ci
2591cb0ef41Sopenharmony_cifunction validateHints(hints) {
2601cb0ef41Sopenharmony_ci  const { AI_ADDRCONFIG, AI_ALL, AI_V4MAPPED } = lazyBinding();
2611cb0ef41Sopenharmony_ci  if ((hints & ~(AI_ADDRCONFIG | AI_ALL | AI_V4MAPPED)) !== 0) {
2621cb0ef41Sopenharmony_ci    throw new ERR_INVALID_ARG_VALUE('hints', hints);
2631cb0ef41Sopenharmony_ci  }
2641cb0ef41Sopenharmony_ci}
2651cb0ef41Sopenharmony_ci
2661cb0ef41Sopenharmony_cilet invalidHostnameWarningEmitted = false;
2671cb0ef41Sopenharmony_cifunction emitInvalidHostnameWarning(hostname) {
2681cb0ef41Sopenharmony_ci  if (!invalidHostnameWarningEmitted) {
2691cb0ef41Sopenharmony_ci    process.emitWarning(
2701cb0ef41Sopenharmony_ci      `The provided hostname "${hostname}" is not a valid ` +
2711cb0ef41Sopenharmony_ci      'hostname, and is supported in the dns module solely for compatibility.',
2721cb0ef41Sopenharmony_ci      'DeprecationWarning',
2731cb0ef41Sopenharmony_ci      'DEP0118',
2741cb0ef41Sopenharmony_ci    );
2751cb0ef41Sopenharmony_ci    invalidHostnameWarningEmitted = true;
2761cb0ef41Sopenharmony_ci  }
2771cb0ef41Sopenharmony_ci}
2781cb0ef41Sopenharmony_ci
2791cb0ef41Sopenharmony_cifunction getDefaultVerbatim() {
2801cb0ef41Sopenharmony_ci  return dnsOrder !== 'ipv4first';
2811cb0ef41Sopenharmony_ci}
2821cb0ef41Sopenharmony_ci
2831cb0ef41Sopenharmony_cifunction setDefaultResultOrder(value) {
2841cb0ef41Sopenharmony_ci  validateOneOf(value, 'dnsOrder', ['verbatim', 'ipv4first']);
2851cb0ef41Sopenharmony_ci  dnsOrder = value;
2861cb0ef41Sopenharmony_ci}
2871cb0ef41Sopenharmony_ci
2881cb0ef41Sopenharmony_cifunction getDefaultResultOrder() {
2891cb0ef41Sopenharmony_ci  return dnsOrder;
2901cb0ef41Sopenharmony_ci}
2911cb0ef41Sopenharmony_ci
2921cb0ef41Sopenharmony_cifunction createResolverClass(resolver) {
2931cb0ef41Sopenharmony_ci  const resolveMap = ObjectCreate(null);
2941cb0ef41Sopenharmony_ci
2951cb0ef41Sopenharmony_ci  class Resolver extends ResolverBase {}
2961cb0ef41Sopenharmony_ci
2971cb0ef41Sopenharmony_ci  Resolver.prototype.resolveAny = resolveMap.ANY = resolver('queryAny');
2981cb0ef41Sopenharmony_ci  Resolver.prototype.resolve4 = resolveMap.A = resolver('queryA');
2991cb0ef41Sopenharmony_ci  Resolver.prototype.resolve6 = resolveMap.AAAA = resolver('queryAaaa');
3001cb0ef41Sopenharmony_ci  Resolver.prototype.resolveCaa = resolveMap.CAA = resolver('queryCaa');
3011cb0ef41Sopenharmony_ci  Resolver.prototype.resolveCname = resolveMap.CNAME = resolver('queryCname');
3021cb0ef41Sopenharmony_ci  Resolver.prototype.resolveMx = resolveMap.MX = resolver('queryMx');
3031cb0ef41Sopenharmony_ci  Resolver.prototype.resolveNs = resolveMap.NS = resolver('queryNs');
3041cb0ef41Sopenharmony_ci  Resolver.prototype.resolveTxt = resolveMap.TXT = resolver('queryTxt');
3051cb0ef41Sopenharmony_ci  Resolver.prototype.resolveSrv = resolveMap.SRV = resolver('querySrv');
3061cb0ef41Sopenharmony_ci  Resolver.prototype.resolvePtr = resolveMap.PTR = resolver('queryPtr');
3071cb0ef41Sopenharmony_ci  Resolver.prototype.resolveNaptr = resolveMap.NAPTR = resolver('queryNaptr');
3081cb0ef41Sopenharmony_ci  Resolver.prototype.resolveSoa = resolveMap.SOA = resolver('querySoa');
3091cb0ef41Sopenharmony_ci  Resolver.prototype.reverse = resolver('getHostByAddr');
3101cb0ef41Sopenharmony_ci
3111cb0ef41Sopenharmony_ci  return {
3121cb0ef41Sopenharmony_ci    resolveMap,
3131cb0ef41Sopenharmony_ci    Resolver,
3141cb0ef41Sopenharmony_ci  };
3151cb0ef41Sopenharmony_ci}
3161cb0ef41Sopenharmony_ci
3171cb0ef41Sopenharmony_ci// ERROR CODES
3181cb0ef41Sopenharmony_ciconst errorCodes = {
3191cb0ef41Sopenharmony_ci  NODATA: 'ENODATA',
3201cb0ef41Sopenharmony_ci  FORMERR: 'EFORMERR',
3211cb0ef41Sopenharmony_ci  SERVFAIL: 'ESERVFAIL',
3221cb0ef41Sopenharmony_ci  NOTFOUND: 'ENOTFOUND',
3231cb0ef41Sopenharmony_ci  NOTIMP: 'ENOTIMP',
3241cb0ef41Sopenharmony_ci  REFUSED: 'EREFUSED',
3251cb0ef41Sopenharmony_ci  BADQUERY: 'EBADQUERY',
3261cb0ef41Sopenharmony_ci  BADNAME: 'EBADNAME',
3271cb0ef41Sopenharmony_ci  BADFAMILY: 'EBADFAMILY',
3281cb0ef41Sopenharmony_ci  BADRESP: 'EBADRESP',
3291cb0ef41Sopenharmony_ci  CONNREFUSED: 'ECONNREFUSED',
3301cb0ef41Sopenharmony_ci  TIMEOUT: 'ETIMEOUT',
3311cb0ef41Sopenharmony_ci  EOF: 'EOF',
3321cb0ef41Sopenharmony_ci  FILE: 'EFILE',
3331cb0ef41Sopenharmony_ci  NOMEM: 'ENOMEM',
3341cb0ef41Sopenharmony_ci  DESTRUCTION: 'EDESTRUCTION',
3351cb0ef41Sopenharmony_ci  BADSTR: 'EBADSTR',
3361cb0ef41Sopenharmony_ci  BADFLAGS: 'EBADFLAGS',
3371cb0ef41Sopenharmony_ci  NONAME: 'ENONAME',
3381cb0ef41Sopenharmony_ci  BADHINTS: 'EBADHINTS',
3391cb0ef41Sopenharmony_ci  NOTINITIALIZED: 'ENOTINITIALIZED',
3401cb0ef41Sopenharmony_ci  LOADIPHLPAPI: 'ELOADIPHLPAPI',
3411cb0ef41Sopenharmony_ci  ADDRGETNETWORKPARAMS: 'EADDRGETNETWORKPARAMS',
3421cb0ef41Sopenharmony_ci  CANCELLED: 'ECANCELLED',
3431cb0ef41Sopenharmony_ci};
3441cb0ef41Sopenharmony_ci
3451cb0ef41Sopenharmony_cimodule.exports = {
3461cb0ef41Sopenharmony_ci  bindDefaultResolver,
3471cb0ef41Sopenharmony_ci  getDefaultResolver,
3481cb0ef41Sopenharmony_ci  setDefaultResolver,
3491cb0ef41Sopenharmony_ci  validateHints,
3501cb0ef41Sopenharmony_ci  validateTimeout,
3511cb0ef41Sopenharmony_ci  validateTries,
3521cb0ef41Sopenharmony_ci  emitInvalidHostnameWarning,
3531cb0ef41Sopenharmony_ci  getDefaultVerbatim,
3541cb0ef41Sopenharmony_ci  getDefaultResultOrder,
3551cb0ef41Sopenharmony_ci  setDefaultResultOrder,
3561cb0ef41Sopenharmony_ci  errorCodes,
3571cb0ef41Sopenharmony_ci  createResolverClass,
3581cb0ef41Sopenharmony_ci  initializeDns,
3591cb0ef41Sopenharmony_ci};
360