tangerine 1.5.1 → 1.5.3
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/README.md +16 -14
- package/index.js +5 -3
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
<h1 align="center">
|
|
2
|
-
<a href="https://github.com/forwardemail/tangerine"><img src="https://raw.githubusercontent.com/forwardemail/tangerine/main/media/header.png" alt="Tangerine" /></a>
|
|
2
|
+
<a href="https://github.com/forwardemail/nodejs-dns-over-https-tangerine"><img src="https://raw.githubusercontent.com/forwardemail/nodejs-dns-over-https-tangerine/main/media/header.png" alt="Tangerine" /></a>
|
|
3
3
|
</h1>
|
|
4
4
|
<div align="center">
|
|
5
|
-
<a href="https://github.com/forwardemail/tangerine/actions/workflows/ci.yml"><img src="https://github.com/forwardemail/tangerine/actions/workflows/ci.yml/badge.svg" alt="build status" /></a>
|
|
5
|
+
<a href="https://github.com/forwardemail/nodejs-dns-over-https-tangerine/actions/workflows/ci.yml"><img src="https://github.com/forwardemail/nodejs-dns-over-https-tangerine/actions/workflows/ci.yml/badge.svg" alt="build status" /></a>
|
|
6
6
|
<a href="https://github.com/sindresorhus/xo"><img src="https://img.shields.io/badge/code_style-XO-5ed9c7.svg" alt="code style" /></a>
|
|
7
7
|
<a href="https://github.com/prettier/prettier"><img src="https://img.shields.io/badge/styled_with-prettier-ff69b4.svg" alt="styled with prettier" /></a>
|
|
8
8
|
<a href="https://lass.js.org"><img src="https://img.shields.io/badge/made_with-lass-95CC28.svg" alt="made with lass" /></a>
|
|
9
|
-
<a href="LICENSE"><img src="https://img.shields.io/github/license/forwardemail/tangerine.svg" alt="license" /></a>
|
|
9
|
+
<a href="LICENSE"><img src="https://img.shields.io/github/license/forwardemail/nodejs-dns-over-https-tangerine.svg" alt="license" /></a>
|
|
10
10
|
<a href="https://npm.im/tangerine"><img src="https://img.shields.io/npm/dt/tangerine.svg" alt="npm downloads" /></a>
|
|
11
11
|
</div>
|
|
12
12
|
<br />
|
|
13
13
|
<div align="center">
|
|
14
|
-
🍊 <a href="https://github.com/forwardemail/tangerine" target="_blank">Tangerine</a> is the best <a href="https://nodejs.org" target="_blank">Node.js</a> drop-in replacement for <a href="https://nodejs.org/api/dns.html#resolveroptions" target="_blank">dns.promises.Resolver</a> using <a href="https://en.wikipedia.org/wiki/DNS_over_HTTPS" target="_blank">DNS over HTTPS</a> ("DoH") via <a href="https://github.com/nodejs/undici" target="_blank">undici</a> with built-in retries, timeouts, smart server rotation, <a href="https://developer.mozilla.org/en-US/docs/Web/API/AbortController" target="_blank">AbortControllers</a>, and caching support for multiple backends (with TTL and purge support).
|
|
14
|
+
🍊 <a href="https://github.com/forwardemail/nodejs-dns-over-https-tangerine" target="_blank">Tangerine</a> is the best <a href="https://nodejs.org" target="_blank">Node.js</a> drop-in replacement for <a href="https://nodejs.org/api/dns.html#resolveroptions" target="_blank">dns.promises.Resolver</a> using <a href="https://en.wikipedia.org/wiki/DNS_over_HTTPS" target="_blank">DNS over HTTPS</a> ("DoH") via <a href="https://github.com/nodejs/undici" target="_blank">undici</a> with built-in retries, timeouts, smart server rotation, <a href="https://developer.mozilla.org/en-US/docs/Web/API/AbortController" target="_blank">AbortControllers</a>, and caching support for multiple backends (with TTL and purge support).
|
|
15
15
|
</div>
|
|
16
16
|
<hr />
|
|
17
17
|
<div align="center">
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
* [`tangerine.reverse(ip[, abortController, purgeCache])`](#tangerinereverseip-abortcontroller-purgecache)
|
|
57
57
|
* [`tangerine.setDefaultResultOrder(order)`](#tangerinesetdefaultresultorderorder)
|
|
58
58
|
* [`tangerine.setServers(servers)`](#tangerinesetserversservers)
|
|
59
|
-
* [`tangerine.spoofPacket(hostname, rrtype, answers[, json])`](#tangerinespoofpackethostname-rrtype-answers-json)
|
|
59
|
+
* [`tangerine.spoofPacket(hostname, rrtype, answers[, json, expires = 30000])`](#tangerinespoofpackethostname-rrtype-answers-json-expires--30000)
|
|
60
60
|
* [Options](#options)
|
|
61
61
|
* [Cache](#cache)
|
|
62
62
|
* [Compatibility](#compatibility)
|
|
@@ -228,7 +228,7 @@ tangerine.resolve('forwardemail.net').then(console.log);
|
|
|
228
228
|
|
|
229
229
|
* Specify default request options based off the library under `requestOptions` below
|
|
230
230
|
* Instance methods of [dns.promises.Resolver](https://nodejs.org/api/dns.html) are mirrored to :tangerine: Tangerine.
|
|
231
|
-
* Resolver methods accept an optional `abortController` argument, which is an instance of [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController). Note that :tangerine: Tangerine manages `AbortController` usage internally – so you most likely won't need to pass your own (see [index.js](https://github.com/forwardemail/tangerine/blob/main/index.js) for more insight).
|
|
231
|
+
* Resolver methods accept an optional `abortController` argument, which is an instance of [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController). Note that :tangerine: Tangerine manages `AbortController` usage internally – so you most likely won't need to pass your own (see [index.js](https://github.com/forwardemail/nodejs-dns-over-https-tangerine/blob/main/index.js) for more insight).
|
|
232
232
|
* Resolver methods that accept `options` argument also accept an optional `options.purgeCache` option.
|
|
233
233
|
* Resolver methods support a `purgeCache` option as either `options.purgeCache` (Boolean) via `options` argument or `purgeCache` (Boolean) argument – see [API](#api) and [Cache](#cache) for more insight.
|
|
234
234
|
* If set to `true`, then the result will be re-queried and re-cached – see [Cache](#cache) documentation for more insight.
|
|
@@ -295,7 +295,7 @@ This mirrors output from <https://github.com/rthalley/dnspython>.
|
|
|
295
295
|
|
|
296
296
|
### `tangerine.resolveTlsa(hostname[, options, abortController]))`
|
|
297
297
|
|
|
298
|
-
This method was added for DANE and TLSA support. See this [excellent article](https://www.mailhardener.com/kb/dane), [index.js](https://github.com/forwardemail/tangerine/blob/main/index.js), and <https://github.com/nodejs/node/issues/39569> for more insight.
|
|
298
|
+
This method was added for DANE and TLSA support. See this [excellent article](https://www.mailhardener.com/kb/dane), [index.js](https://github.com/forwardemail/nodejs-dns-over-https-tangerine/blob/main/index.js), and <https://github.com/nodejs/node/issues/39569> for more insight.
|
|
299
299
|
|
|
300
300
|
This function returns a Promise that resolves with an Array with parsed values from results:
|
|
301
301
|
|
|
@@ -332,7 +332,7 @@ This mirrors output from <https://github.com/rthalley/dnspython>.
|
|
|
332
332
|
|
|
333
333
|
### `tangerine.setServers(servers)`
|
|
334
334
|
|
|
335
|
-
### `tangerine.spoofPacket(hostname, rrtype, answers[, json])`
|
|
335
|
+
### `tangerine.spoofPacket(hostname, rrtype, answers[, json, expires = 30000])`
|
|
336
336
|
|
|
337
337
|
This method is useful for writing tests to spoof DNS packets in-memory.
|
|
338
338
|
|
|
@@ -340,6 +340,8 @@ The `rrtype` must be either `"TXT"` or `"MX"`, and `answers` must be an Array of
|
|
|
340
340
|
|
|
341
341
|
If you pass `json` as `true`, then value returned will be converted to JSON via `JSON.stringify`.
|
|
342
342
|
|
|
343
|
+
The last argument `expires` can either be a `Date` or `Number`. This is the value used for calculating the DNS packet expiration. If it is a `Number`, then the `expires` value will be `Date.now() + expires`. The default value is `30000`, which means it will expire in 30 seconds.
|
|
344
|
+
|
|
343
345
|
For example, if you want to spoof TXT and MX records:
|
|
344
346
|
|
|
345
347
|
```js
|
|
@@ -379,7 +381,7 @@ console.log('mx', mx);
|
|
|
379
381
|
|
|
380
382
|
## Options
|
|
381
383
|
|
|
382
|
-
Similar to the `options` argument from `new dns.promises.Resolver(options)` invocation – :tangerine: Tangerine also has its own options with default `dns` behavior mirrored. See [index.js](https://github.com/forwardemail/tangerine/blob/main/index.js) for more insight into how these options work.
|
|
384
|
+
Similar to the `options` argument from `new dns.promises.Resolver(options)` invocation – :tangerine: Tangerine also has its own options with default `dns` behavior mirrored. See [index.js](https://github.com/forwardemail/nodejs-dns-over-https-tangerine/blob/main/index.js) for more insight into how these options work.
|
|
383
385
|
|
|
384
386
|
| Property | Type | Default Value | Description |
|
|
385
387
|
| ------------------------- | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -505,7 +507,7 @@ If you run into issues while using :tangerine: Tangerine, then these recommendat
|
|
|
505
507
|
Contributors can run benchmarks locally by cloning the repository, installing dependencies, and running the benchmarks script:
|
|
506
508
|
|
|
507
509
|
```sh
|
|
508
|
-
git clone https://github.com/forwardemail/tangerine.git
|
|
510
|
+
git clone https://github.com/forwardemail/nodejs-dns-over-https-tangerine.git
|
|
509
511
|
cd tangerine
|
|
510
512
|
npm install
|
|
511
513
|
npm run benchmarks
|
|
@@ -521,9 +523,9 @@ BENCHMARK_PROTOCOL="http" BENCHMARK_HOST="127.0.0.1" BENCHMARK_PORT="4000" BENCH
|
|
|
521
523
|
|
|
522
524
|
We have written extensive benchmarks to show that :tangerine: Tangerine is as fast as the native Node.js DNS module (with the exception of the `lookup` command). Note that performance is opinionated – since rate limiting plays a factor dependent on the DNS servers you are using and since caching is most likely going to takeover.
|
|
523
525
|
|
|
524
|
-
The latest benchmark results are viewable on GitHub under this repository's [GitHub CI actions logs](https://github.com/forwardemail/tangerine/actions?query=event%3Apush):
|
|
526
|
+
The latest benchmark results are viewable on GitHub under this repository's [GitHub CI actions logs](https://github.com/forwardemail/nodejs-dns-over-https-tangerine/actions?query=event%3Apush):
|
|
525
527
|
|
|
526
|
-
> [Node 16 on ubuntu-latest](https://github.com/forwardemail/tangerine/actions/runs/4297805550/jobs/7491228635#step:6:1)
|
|
528
|
+
> [Node 16 on ubuntu-latest](https://github.com/forwardemail/nodejs-dns-over-https-tangerine/actions/runs/4297805550/jobs/7491228635#step:6:1)
|
|
527
529
|
|
|
528
530
|
```diff
|
|
529
531
|
node benchmarks/lookup && node benchmarks/resolve && node benchmarks/reverse
|
|
@@ -560,7 +562,7 @@ dns.promises.reverse with caching x 5,123,900 ops/sec ±0.96% (85 runs sampled)
|
|
|
560
562
|
+Fastest without caching is: tangerine.reverse GET without caching
|
|
561
563
|
```
|
|
562
564
|
|
|
563
|
-
> [Node 18 on ubuntu latest](https://github.com/forwardemail/tangerine/actions/runs/4297805550/jobs/7491228742#step:6:1)
|
|
565
|
+
> [Node 18 on ubuntu latest](https://github.com/forwardemail/nodejs-dns-over-https-tangerine/actions/runs/4297805550/jobs/7491228742#step:6:1)
|
|
564
566
|
|
|
565
567
|
```diff
|
|
566
568
|
node benchmarks/lookup && node benchmarks/resolve && node benchmarks/reverse && node benchmarks/http
|
|
@@ -734,4 +736,4 @@ Fastest is undici GET request
|
|
|
734
736
|
|
|
735
737
|
##
|
|
736
738
|
|
|
737
|
-
<a href="#"><img src="https://raw.githubusercontent.com/forwardemail/tangerine/main/media/footer.png" alt="#" /></a>
|
|
739
|
+
<a href="#"><img src="https://raw.githubusercontent.com/forwardemail/nodejs-dns-over-https-tangerine/main/media/footer.png" alt="#" /></a>
|
package/index.js
CHANGED
|
@@ -1425,7 +1425,8 @@ class Tangerine extends dns.promises.Resolver {
|
|
|
1425
1425
|
this.options.servers = new Set(servers);
|
|
1426
1426
|
}
|
|
1427
1427
|
|
|
1428
|
-
|
|
1428
|
+
// eslint-disable-next-line max-params
|
|
1429
|
+
spoofPacket(name, rrtype, answers = [], json = false, expires = 30000) {
|
|
1429
1430
|
if (typeof name !== 'string') {
|
|
1430
1431
|
const err = new TypeError('The "name" argument must be of type string.');
|
|
1431
1432
|
err.code = 'ERR_INVALID_ARG_TYPE';
|
|
@@ -1489,7 +1490,8 @@ class Tangerine extends dns.promises.Resolver {
|
|
|
1489
1490
|
}
|
|
1490
1491
|
],
|
|
1491
1492
|
ttl: 300,
|
|
1492
|
-
expires:
|
|
1493
|
+
expires:
|
|
1494
|
+
expires instanceof Date ? expires.getTime() : Date.now() + expires
|
|
1493
1495
|
};
|
|
1494
1496
|
|
|
1495
1497
|
return json ? JSON.stringify(obj) : obj;
|
|
@@ -1954,7 +1956,7 @@ class Tangerine extends dns.promises.Resolver {
|
|
|
1954
1956
|
default: {
|
|
1955
1957
|
this.options.logger.error(
|
|
1956
1958
|
new Error(
|
|
1957
|
-
`Submit a PR at <https://github.com/forwardemail/tangerine> with proper parsing for ${rrtype} records. You can reference <https://github.com/rthalley/dnspython/tree/master/dns/rdtypes/ANY> for inspiration.`
|
|
1959
|
+
`Submit a PR at <https://github.com/forwardemail/nodejs-dns-over-https-tangerine> with proper parsing for ${rrtype} records. You can reference <https://github.com/rthalley/dnspython/tree/master/dns/rdtypes/ANY> for inspiration.`
|
|
1958
1960
|
)
|
|
1959
1961
|
);
|
|
1960
1962
|
return result.answers;
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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.5.
|
|
4
|
+
"version": "1.5.3",
|
|
5
5
|
"author": "Forward Email (https://forwardemail.net)",
|
|
6
6
|
"bugs": {
|
|
7
|
-
"url": "https://github.com/forwardemail/tangerine/issues"
|
|
7
|
+
"url": "https://github.com/forwardemail/nodejs-dns-over-https-tangerine/issues"
|
|
8
8
|
},
|
|
9
9
|
"contributors": [
|
|
10
10
|
"Forward Email (https://forwardemail.net)"
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"files": [
|
|
63
63
|
"index.js"
|
|
64
64
|
],
|
|
65
|
-
"homepage": "https://github.com/forwardemail/tangerine",
|
|
65
|
+
"homepage": "https://github.com/forwardemail/nodejs-dns-over-https-tangerine",
|
|
66
66
|
"keywords": [
|
|
67
67
|
"1:1",
|
|
68
68
|
"abort",
|
|
@@ -153,7 +153,7 @@
|
|
|
153
153
|
},
|
|
154
154
|
"repository": {
|
|
155
155
|
"type": "git",
|
|
156
|
-
"url": "https://github.com/forwardemail/tangerine"
|
|
156
|
+
"url": "https://github.com/forwardemail/nodejs-dns-over-https-tangerine"
|
|
157
157
|
},
|
|
158
158
|
"scripts": {
|
|
159
159
|
"ava": "cross-env NODE_ENV=test ava",
|