mirror of
https://github.com/smartyellow/status.git
synced 2025-01-18 05:27:58 +00:00
Force requests over IPv4
This commit is contained in:
parent
40309edc1f
commit
8ef7122811
@ -3,6 +3,12 @@
|
||||
const fetch = require('node-fetch');
|
||||
const { operators } = require('./operators');
|
||||
const { realValues } = require('./realvalues');
|
||||
const http = require('http');
|
||||
const https = require('https');
|
||||
|
||||
// Force requests over IPv4
|
||||
const httpAgent = new http.Agent({ family: 4 });
|
||||
const httpsAgent = new https.Agent({ family: 4 });
|
||||
|
||||
async function testEndpoints(endpoints) {
|
||||
const output = {
|
||||
@ -20,7 +26,15 @@ async function testEndpoints(endpoints) {
|
||||
return obj;
|
||||
}, {});
|
||||
|
||||
const res = await fetch(endpoint.uri, { headers });
|
||||
const res = await fetch(endpoint.uri, {
|
||||
headers,
|
||||
agent: url => {
|
||||
if (url.protocol === 'http:') {
|
||||
return httpAgent;
|
||||
}
|
||||
return httpsAgent;
|
||||
},
|
||||
});
|
||||
const body = await res.text();
|
||||
|
||||
endpoint.requirements.forEach(requirement => {
|
||||
|
Loading…
Reference in New Issue
Block a user