-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
33 lines (25 loc) · 815 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var dns = require('dns');
var originalLookup = dns.lookup;
dns.lookup = function (hostname, options, callback) {
var type = typeof options;
if (type === 'function') {
callback = options;
}
if (type === 'object') {
var opts = Object.assign({}, options);
opts.family = 4;
return originalLookup(hostname, opts, callback);
}
return originalLookup(hostname, 4, callback);
};
if (dns.promises) {
var originalPromiseLookup = dns.promises.lookup;
dns.promises.lookup = function (hostname, options) {
if (typeof options === 'object') {
var opts = Object.assign({}, options);
opts.family = 4;
return originalPromiseLookup(hostname, opts);
}
return originalPromiseLookup(hostname, 4);
};
}