tangerine 1.4.0 → 1.4.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.
- package/index.js +20 -11
- package/package.json +2 -1
package/index.js
CHANGED
|
@@ -7,7 +7,7 @@ const { debuglog } = require('node:util');
|
|
|
7
7
|
const { getEventListeners, setMaxListeners } = require('node:events');
|
|
8
8
|
const { isIP, isIPv4, isIPv6 } = require('node:net');
|
|
9
9
|
|
|
10
|
-
const
|
|
10
|
+
const autoBind = require('auto-bind');
|
|
11
11
|
const getStream = require('get-stream');
|
|
12
12
|
const ipaddr = require('ipaddr.js');
|
|
13
13
|
const mergeOptions = require('merge-options');
|
|
@@ -18,6 +18,8 @@ const packet = require('dns-packet');
|
|
|
18
18
|
const semver = require('semver');
|
|
19
19
|
const structuredClone = require('@ungap/structured-clone').default;
|
|
20
20
|
const { getService } = require('port-numbers');
|
|
21
|
+
// eslint-disable-next-line import/order
|
|
22
|
+
const { toASCII } = require('punycode/');
|
|
21
23
|
|
|
22
24
|
const pkg = require('./package.json');
|
|
23
25
|
|
|
@@ -363,6 +365,13 @@ class Tangerine extends dns.promises.Resolver {
|
|
|
363
365
|
|
|
364
366
|
// manage set of abort controllers
|
|
365
367
|
this.abortControllers = new Set();
|
|
368
|
+
|
|
369
|
+
//
|
|
370
|
+
// NOTE: bind methods so we don't have to programmatically call `.bind`
|
|
371
|
+
// (e.g. `getDmarcRecord(name, resolver.resolve.bind(resolver))`)
|
|
372
|
+
// (alternative to `autoBind(this)` is `this[method] = this[method].bind(this)`)
|
|
373
|
+
//
|
|
374
|
+
autoBind(this);
|
|
366
375
|
}
|
|
367
376
|
|
|
368
377
|
setLocalAddress(ipv4, ipv6) {
|
|
@@ -455,7 +464,7 @@ class Tangerine extends dns.promises.Resolver {
|
|
|
455
464
|
|
|
456
465
|
// if options is an integer, it must be 4 or 6
|
|
457
466
|
if (typeof options === 'number') {
|
|
458
|
-
if (options !== 4 && options !== 6) {
|
|
467
|
+
if (options !== 0 && options !== 4 && options !== 6) {
|
|
459
468
|
const err = new TypeError(
|
|
460
469
|
`The argument 'family' must be one of: 0, 4, 6. Received ${options}`
|
|
461
470
|
);
|
|
@@ -479,6 +488,8 @@ class Tangerine extends dns.promises.Resolver {
|
|
|
479
488
|
if (options?.family === 'IPv4') options.family = 4;
|
|
480
489
|
else if (options?.family === 'IPv6') options.family = 6;
|
|
481
490
|
|
|
491
|
+
if (typeof options.family !== 'number') options.family = 0;
|
|
492
|
+
|
|
482
493
|
// validate hints
|
|
483
494
|
// eslint-disable-next-line no-bitwise
|
|
484
495
|
if ((options?.hints & ~(dns.ADDRCONFIG | dns.ALL | dns.V4MAPPED)) !== 0) {
|
|
@@ -526,18 +537,16 @@ class Tangerine extends dns.promises.Resolver {
|
|
|
526
537
|
let answers = [];
|
|
527
538
|
|
|
528
539
|
try {
|
|
529
|
-
|
|
530
|
-
// (according to official nodejs dns.lookup docs)
|
|
531
|
-
answers = await Promise[
|
|
532
|
-
typeof options.family === 'undefined' || options.family === 0
|
|
533
|
-
? 'all'
|
|
534
|
-
: 'any'
|
|
535
|
-
]([
|
|
536
|
-
// the only downside here is that if one succeeds the other won't be aborted (iff "any")
|
|
540
|
+
answers = await Promise.all([
|
|
537
541
|
this.resolve4(name, { purgeCache, noThrowOnNODATA: true }),
|
|
538
542
|
this.resolve6(name, { purgeCache, noThrowOnNODATA: true })
|
|
539
543
|
]);
|
|
540
|
-
|
|
544
|
+
// default node behavior seems to return IPv4 by default always regardless
|
|
545
|
+
answers =
|
|
546
|
+
answers[0].length > 0 &&
|
|
547
|
+
(typeof options.family === 'undefined' || options.family === 0)
|
|
548
|
+
? answers[0]
|
|
549
|
+
: answers.flat();
|
|
541
550
|
} catch (_err) {
|
|
542
551
|
debug(_err);
|
|
543
552
|
|
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 (with TTL and purge support).",
|
|
4
|
-
"version": "1.4.
|
|
4
|
+
"version": "1.4.2",
|
|
5
5
|
"author": "Forward Email (https://forwardemail.net)",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/forwardemail/tangerine/issues"
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@ungap/structured-clone": "^1.0.2",
|
|
14
|
+
"auto-bind": "4",
|
|
14
15
|
"dns-packet": "^5.4.0",
|
|
15
16
|
"dohdec": "^5.0.3",
|
|
16
17
|
"get-stream": "6",
|