@nxtedition/nxt-undici 3.1.2 → 3.1.4
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/lib/interceptor/dns.js +5 -5
- package/package.json +1 -1
package/lib/interceptor/dns.js
CHANGED
|
@@ -50,20 +50,20 @@ export default (opts) => (dispatch) => (opts, handler) => {
|
|
|
50
50
|
assert(typeof dns.lookup === 'function')
|
|
51
51
|
assert(typeof dns.clear === 'function')
|
|
52
52
|
|
|
53
|
-
const
|
|
54
|
-
const hostname = url.hostname
|
|
53
|
+
const { hostname } = new URL(opts.origin)
|
|
55
54
|
|
|
56
|
-
const callback = (err,
|
|
55
|
+
const callback = (err, entries) => {
|
|
57
56
|
if (err) {
|
|
58
57
|
handler.onConnect(() => {})
|
|
59
58
|
handler.onError(err)
|
|
60
59
|
} else {
|
|
61
|
-
url
|
|
60
|
+
const url = new URL(opts.origin)
|
|
61
|
+
url.hostname = entries[entries.length * Math.random()].address
|
|
62
62
|
dispatch({ ...opts, origin: url.origin }, new Handler(opts, hostname, { handler }))
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
const thenable = dns.lookup(
|
|
66
|
+
const thenable = dns.lookup(hostname, { all: true }, callback)
|
|
67
67
|
if (typeof thenable?.then === 'function') {
|
|
68
68
|
thenable.then(
|
|
69
69
|
(val) => callback(null, val),
|