@tryghost/domain-validator 1.2.1 → 1.4.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/lib/request.js +26 -1
- package/package.json +7 -7
package/lib/request.js
CHANGED
|
@@ -4,7 +4,31 @@ const Promise = require('bluebird');
|
|
|
4
4
|
const errors = require('@tryghost/errors');
|
|
5
5
|
const debug = require('@tryghost/debug')('dv:request');
|
|
6
6
|
|
|
7
|
+
// Use 3rd party DNS resolver
|
|
8
|
+
const http = require('http');
|
|
9
|
+
const https = require('https');
|
|
10
|
+
const {Resolver} = require('dns').promises;
|
|
11
|
+
const resolver = new Resolver();
|
|
12
|
+
resolver.setServers(['1.1.1.1', '1.0.0.1']);
|
|
13
|
+
|
|
14
|
+
const staticLookup = () => async (hostname, _options, callback) => {
|
|
15
|
+
try {
|
|
16
|
+
const ips = await resolver.resolve(hostname);
|
|
17
|
+
|
|
18
|
+
if (ips.length === 0) {
|
|
19
|
+
return callback(new Error(`Unable to resolve ${hostname}`));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
callback(null, ips[0], 4);
|
|
23
|
+
} catch (err) {
|
|
24
|
+
return callback(err);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
7
28
|
module.exports.domain = (url) => {
|
|
29
|
+
const httpModule = new URL(url).protocol === 'https:' ? https : http;
|
|
30
|
+
const httpAgent = new httpModule.Agent({lookup: staticLookup()});
|
|
31
|
+
|
|
8
32
|
const options = {
|
|
9
33
|
// We want to capture details of different hops
|
|
10
34
|
followRedirect: false,
|
|
@@ -14,7 +38,8 @@ module.exports.domain = (url) => {
|
|
|
14
38
|
retries: 1,
|
|
15
39
|
headers: {
|
|
16
40
|
'X-Ghost-Proxy': true
|
|
17
|
-
}
|
|
41
|
+
},
|
|
42
|
+
agent: httpAgent
|
|
18
43
|
};
|
|
19
44
|
|
|
20
45
|
const responses = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/domain-validator",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "ssh://git@github.com/TryGhost/Pro",
|
|
@@ -25,18 +25,18 @@
|
|
|
25
25
|
"test": "NODE_ENV=testing mocha -- $(find test -name '*.test.js')"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"mocha": "8.
|
|
28
|
+
"mocha": "8.4.0",
|
|
29
29
|
"should": "13.2.3",
|
|
30
|
-
"sinon": "9.
|
|
30
|
+
"sinon": "9.2.4"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@tryghost/debug": "0.1.17",
|
|
34
|
-
"@tryghost/dns": "^0.
|
|
35
|
-
"@tryghost/errors": "1.2.
|
|
34
|
+
"@tryghost/dns": "^0.5.0",
|
|
35
|
+
"@tryghost/errors": "1.2.14",
|
|
36
36
|
"@tryghost/pretty-cli": "1.2.9",
|
|
37
37
|
"bluebird": "3.7.2",
|
|
38
38
|
"got": "8.3.2",
|
|
39
|
-
"lodash": "4.17.
|
|
39
|
+
"lodash": "4.17.21"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "eae1ae68d37265c73f5b18ea1f35477a739a1bac"
|
|
42
42
|
}
|