tangerine 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +14 -4
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -286,6 +286,8 @@ class Resolver extends dns.promises.Resolver {
286
286
  // if `cache: false` then caching is disabled
287
287
  // but note that this doesn't disable `got` dnsCache which is separate
288
288
  // so to turn that off, you need to supply `dnsCache: undefined` in `got` object (?)
289
+ if (this.options.cache === true) this.options.cache = new Map();
290
+
289
291
  if (this.options.cache instanceof Map) {
290
292
  // each of the types have their own Keyv with prefix
291
293
  for (const type of this.constructor.TYPES) {
@@ -502,7 +504,9 @@ class Resolver extends dns.promises.Resolver {
502
504
 
503
505
  case dns.V4MAPPED: {
504
506
  if (options.family === 6 && !answers.some((answer) => isIPv6(answer)))
505
- answers = answers.map((answer) => ipaddr.process(answer));
507
+ answers = answers.map((answer) =>
508
+ ipaddr.parse(answer).toIPv4MappedAddress().toString()
509
+ );
506
510
  break;
507
511
  }
508
512
 
@@ -515,14 +519,18 @@ class Resolver extends dns.promises.Resolver {
515
519
  case dns.ADDRCONFIG | dns.V4MAPPED: {
516
520
  options.family = this.constructor.getAddrConfigTypes();
517
521
  if (options.family === 6 && !answers.some((answer) => isIPv6(answer)))
518
- answers = answers.map((answer) => ipaddr.process(answer));
522
+ answers = answers.map((answer) =>
523
+ ipaddr.parse(answer).toIPv4MappedAddress().toString()
524
+ );
519
525
  break;
520
526
  }
521
527
 
522
528
  // eslint-disable-next-line no-bitwise
523
529
  case dns.V4MAPPED | dns.ALL: {
524
530
  if (options.family === 6 && !answers.some((answer) => isIPv6(answer)))
525
- answers = answers.map((answer) => ipaddr.process(answer));
531
+ answers = answers.map((answer) =>
532
+ ipaddr.parse(answer).toIPv4MappedAddress().toString()
533
+ );
526
534
  options.all = true;
527
535
  break;
528
536
  }
@@ -531,7 +539,9 @@ class Resolver extends dns.promises.Resolver {
531
539
  case dns.ADDRCONFIG | dns.V4MAPPED | dns.ALL: {
532
540
  options.family = this.constructor.getAddrConfigTypes();
533
541
  if (options.family === 6 && !answers.some((answer) => isIPv6(answer)))
534
- answers = answers.map((answer) => ipaddr.process(answer));
542
+ answers = answers.map((answer) =>
543
+ ipaddr.parse(answer).toIPv4MappedAddress().toString()
544
+ );
535
545
  options.all = true;
536
546
 
537
547
  break;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tangerine",
3
3
  "description": "Tangerine is the best Node.js drop-in replacement for dns.promises.Resolver using DNS over HTTPS (\"DoH\") via undici with built-in retries, timeouts, smart server rotation, AbortControllers, and caching support for multiple backends via Keyv.",
4
- "version": "1.0.0",
4
+ "version": "1.0.2",
5
5
  "author": "Forward Email (https://forwardemail.net)",
6
6
  "bugs": {
7
7
  "url": "https://github.com/forwardemail/tangerine/issues"