tangerine 1.5.8 → 1.6.0
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 +1 -1
- package/index.js +9 -11
- package/package.json +2 -4
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
</div>
|
|
16
16
|
<hr />
|
|
17
17
|
<div align="center">
|
|
18
|
-
⚡ <a href="#tangerine-benchmarks"><i><u><strong>AS FAST AS</strong></u></i></a> native <a href="https://nodejs.org/api/dns.html" target="_blank">Node.js <code>dns</code></a>! 🚀 • Supports Node
|
|
18
|
+
⚡ <a href="#tangerine-benchmarks"><i><u><strong>AS FAST AS</strong></u></i></a> native <a href="https://nodejs.org/api/dns.html" target="_blank">Node.js <code>dns</code></a>! 🚀 • Supports Node v17+ with ESM/CJS • Made for <a href="https://forwardemail.net" target="_blank"><strong>Forward Email</strong></a>.
|
|
19
19
|
</div>
|
|
20
20
|
<hr />
|
|
21
21
|
|
package/index.js
CHANGED
|
@@ -14,11 +14,9 @@ const ipaddr = require('ipaddr.js');
|
|
|
14
14
|
const isStream = require('is-stream');
|
|
15
15
|
const mergeOptions = require('merge-options');
|
|
16
16
|
const pMap = require('p-map');
|
|
17
|
-
const pTimeout = require('p-timeout');
|
|
18
17
|
const pWaitFor = require('p-wait-for');
|
|
19
18
|
const packet = require('dns-packet');
|
|
20
19
|
const semver = require('semver');
|
|
21
|
-
const structuredClone = require('@ungap/structured-clone').default;
|
|
22
20
|
const { getService } = require('port-numbers');
|
|
23
21
|
const pkg = require('./package.json');
|
|
24
22
|
|
|
@@ -109,8 +107,6 @@ class Tangerine extends dns.promises.Resolver {
|
|
|
109
107
|
let err;
|
|
110
108
|
if (errors.length === 1) {
|
|
111
109
|
err = errors[0];
|
|
112
|
-
} else if (errors.every((e) => e instanceof pTimeout.TimeoutError)) {
|
|
113
|
-
err = errors[0];
|
|
114
110
|
} else {
|
|
115
111
|
err = new Error(
|
|
116
112
|
[...new Set(errors.map((e) => e.message).filter(Boolean))].join('; ')
|
|
@@ -1043,7 +1039,7 @@ class Tangerine extends dns.promises.Resolver {
|
|
|
1043
1039
|
//
|
|
1044
1040
|
async #request(pkt, server, abortController, timeout = this.options.timeout) {
|
|
1045
1041
|
// safeguard in case aborted
|
|
1046
|
-
|
|
1042
|
+
abortController?.signal?.throwIfAborted();
|
|
1047
1043
|
|
|
1048
1044
|
let localAddress;
|
|
1049
1045
|
let localPort;
|
|
@@ -1067,15 +1063,19 @@ class Tangerine extends dns.promises.Resolver {
|
|
|
1067
1063
|
// <https://github.com/hildjj/dohdec/blob/43564118c40f2127af871bdb4d40f615409d4b9c/pkg/dohdec/lib/doh.js#L117-L120>
|
|
1068
1064
|
if (this.options.requestOptions.method.toLowerCase() === 'get') {
|
|
1069
1065
|
if (!dohdec) await pWaitFor(() => Boolean(dohdec));
|
|
1066
|
+
// safeguard in case aborted
|
|
1067
|
+
abortController?.signal?.throwIfAborted();
|
|
1070
1068
|
url += `?dns=${dohdec.DNSoverHTTPS.base64urlEncode(pkt)}`;
|
|
1071
1069
|
} else {
|
|
1072
1070
|
options.body = pkt;
|
|
1073
1071
|
}
|
|
1074
1072
|
|
|
1075
1073
|
debug('request', { url, options });
|
|
1076
|
-
const
|
|
1077
|
-
signal
|
|
1078
|
-
});
|
|
1074
|
+
const t = setTimeout(() => {
|
|
1075
|
+
if (!abortController?.signal?.aborted) abortController.abort();
|
|
1076
|
+
}, timeout);
|
|
1077
|
+
const response = await this.request(url, options);
|
|
1078
|
+
clearTimeout(t);
|
|
1079
1079
|
return response;
|
|
1080
1080
|
}
|
|
1081
1081
|
|
|
@@ -1237,9 +1237,7 @@ class Tangerine extends dns.promises.Resolver {
|
|
|
1237
1237
|
const err = this.constructor.createError(
|
|
1238
1238
|
name,
|
|
1239
1239
|
rrtype,
|
|
1240
|
-
_err
|
|
1241
|
-
? dns.TIMEOUT
|
|
1242
|
-
: _err.code,
|
|
1240
|
+
_err.code,
|
|
1243
1241
|
_err.errno
|
|
1244
1242
|
);
|
|
1245
1243
|
// then map it to dns.CONNREFUSED
|
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
|
+
"version": "1.6.0",
|
|
5
5
|
"author": "Forward Email (https://forwardemail.net)",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/forwardemail/nodejs-dns-over-https-tangerine/issues"
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
"Forward Email (https://forwardemail.net)"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@ungap/structured-clone": "^1.2.0",
|
|
14
13
|
"auto-bind": "4",
|
|
15
14
|
"dns-packet": "^5.6.1",
|
|
16
15
|
"dohdec": "^5.0.3",
|
|
@@ -20,7 +19,6 @@
|
|
|
20
19
|
"is-stream": "2.0.1",
|
|
21
20
|
"merge-options": "3.0.4",
|
|
22
21
|
"p-map": "4",
|
|
23
|
-
"p-timeout": "4",
|
|
24
22
|
"p-wait-for": "3",
|
|
25
23
|
"port-numbers": "6.0.1",
|
|
26
24
|
"private-ip": "^3.0.2",
|
|
@@ -58,7 +56,7 @@
|
|
|
58
56
|
"xo": "^0.58.0"
|
|
59
57
|
},
|
|
60
58
|
"engines": {
|
|
61
|
-
"node": ">=
|
|
59
|
+
"node": ">=17"
|
|
62
60
|
},
|
|
63
61
|
"files": [
|
|
64
62
|
"index.js"
|