tangerine 1.4.2 → 1.4.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/index.js +54 -8
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1243,7 +1243,7 @@ class Tangerine extends dns.promises.Resolver {
|
|
|
1243
1243
|
data = await this.options.cache.get(key);
|
|
1244
1244
|
// safeguard in case cache pollution
|
|
1245
1245
|
if (data && typeof data === 'object') {
|
|
1246
|
-
debug('cache retrieved',
|
|
1246
|
+
debug('cache retrieved', key);
|
|
1247
1247
|
const now = Date.now();
|
|
1248
1248
|
// safeguard in case cache pollution
|
|
1249
1249
|
if (
|
|
@@ -1252,6 +1252,7 @@ class Tangerine extends dns.promises.Resolver {
|
|
|
1252
1252
|
!Number.isFinite(data.ttl) ||
|
|
1253
1253
|
data.ttl < 1
|
|
1254
1254
|
) {
|
|
1255
|
+
debug('cache expired', key);
|
|
1255
1256
|
data = undefined;
|
|
1256
1257
|
} else if (options?.ttl) {
|
|
1257
1258
|
// clone the data so that we don't mutate cache (e.g. if it's in-memory)
|
|
@@ -1271,6 +1272,7 @@ class Tangerine extends dns.promises.Resolver {
|
|
|
1271
1272
|
|
|
1272
1273
|
// eslint-disable-next-line max-depth
|
|
1273
1274
|
if (data.answers[i].ttl <= 0) {
|
|
1275
|
+
debug('answer cache expired', key);
|
|
1274
1276
|
data = undefined;
|
|
1275
1277
|
break;
|
|
1276
1278
|
}
|
|
@@ -1517,13 +1519,57 @@ class Tangerine extends dns.promises.Resolver {
|
|
|
1517
1519
|
|
|
1518
1520
|
case 'TXT': {
|
|
1519
1521
|
// text records `dnsPromises.resolveTxt()`
|
|
1520
|
-
return result.answers.flatMap((a) =>
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1522
|
+
return result.answers.flatMap((a) => {
|
|
1523
|
+
//
|
|
1524
|
+
// NOTE: we need to support buffer conversion
|
|
1525
|
+
// (e.g. JSON.stringify from most cache stores will convert this as such below)
|
|
1526
|
+
//
|
|
1527
|
+
// a {
|
|
1528
|
+
// name: 'forwardemail.net',
|
|
1529
|
+
// type: 'TXT',
|
|
1530
|
+
// ttl: 3600,
|
|
1531
|
+
// class: 'IN',
|
|
1532
|
+
// flush: false,
|
|
1533
|
+
// data: [ { type: 'Buffer', data: [Array] } ]
|
|
1534
|
+
// }
|
|
1535
|
+
//
|
|
1536
|
+
// (or)
|
|
1537
|
+
//
|
|
1538
|
+
// a {
|
|
1539
|
+
// name: 'forwardemail.net',
|
|
1540
|
+
// type: 'TXT',
|
|
1541
|
+
// ttl: 3600,
|
|
1542
|
+
// class: 'IN',
|
|
1543
|
+
// flush: false,
|
|
1544
|
+
// data: { type: 'Buffer', data: [Array] }
|
|
1545
|
+
// }
|
|
1546
|
+
//
|
|
1547
|
+
if (Array.isArray(a.data)) {
|
|
1548
|
+
a.data = a.data.map((d) => {
|
|
1549
|
+
if (
|
|
1550
|
+
typeof d === 'object' &&
|
|
1551
|
+
d.type === 'Buffer' &&
|
|
1552
|
+
Array.isArray(d.data)
|
|
1553
|
+
)
|
|
1554
|
+
return Buffer.from(d.data);
|
|
1555
|
+
return d;
|
|
1556
|
+
});
|
|
1557
|
+
} else if (
|
|
1558
|
+
typeof a.data === 'object' &&
|
|
1559
|
+
a.data.type === 'Buffer' &&
|
|
1560
|
+
Array.isArray(a.data.data)
|
|
1561
|
+
) {
|
|
1562
|
+
a.data = Buffer.from(a.data.data);
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
return [
|
|
1566
|
+
Buffer.isBuffer(a.data)
|
|
1567
|
+
? a.data.toString()
|
|
1568
|
+
: Array.isArray(a.data)
|
|
1569
|
+
? a.data.map((d) => (Buffer.isBuffer(d) ? d.toString() : d))
|
|
1570
|
+
: a.data
|
|
1571
|
+
];
|
|
1572
|
+
});
|
|
1527
1573
|
}
|
|
1528
1574
|
|
|
1529
1575
|
default: {
|
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.3",
|
|
5
5
|
"author": "Forward Email (https://forwardemail.net)",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/forwardemail/tangerine/issues"
|