-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudfare_dns_checker.js
68 lines (51 loc) · 2.51 KB
/
cloudfare_dns_checker.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import puppeteer from 'puppeteer-extra';
async function fetchConnectionInfo() {
// Launch the browser in headless mode with specified arguments for performance
const browser = await puppeteer.launch({
headless: true,
executablePath: '/usr/bin/chromium-browser',
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-dev-shm-usage',
'--disable-gpu',
'--no-first-run',
'--no-zygote',
'--single-process',
],
});
const page = await browser.newPage();
// Navigate to the Cloudflare 1.1.1.1 help page and wait until the network is idle
await page.goto('https://one.one.one.one/help/', { waitUntil: 'networkidle2' });
console.log("Fetching connection information...");
const connectionInfo = {};
// Fetch the connection details and log them step-by-step
connectionInfo.connectedTo = await page.$eval('td[data-ref="isCf"]', el => el.innerText);
console.log(`Connected to 1.1.1.1: ${connectionInfo.connectedTo}`);
connectionInfo.usingDoH = await page.$eval('td[data-ref="isDoh"]', el => el.innerText);
console.log(`Using DNS over HTTPS (DoH): ${connectionInfo.usingDoH}`);
connectionInfo.usingDoT = await page.$eval('td[data-ref="isDot"]', el => el.innerText);
console.log(`Using DNS over TLS (DoT): ${connectionInfo.usingDoT}`);
connectionInfo.usingWARP = await page.$eval('td[data-ref="isWarp"]', el => el.innerText);
console.log(`Using DNS over WARP: ${connectionInfo.usingWARP}`);
connectionInfo.asName = await page.$eval('td[data-ref="ispName"]', el => el.innerText);
console.log(`AS Name: ${connectionInfo.asName}`);
connectionInfo.asNumber = await page.$eval('td[data-ref="ispAsn"]', el => el.innerText);
console.log(`AS Number: ${connectionInfo.asNumber}`);
connectionInfo.dataCenter = await page.$eval('td[data-ref="datacenterLocation"]', el => el.innerText);
console.log(`Cloudflare Data Center: ${connectionInfo.dataCenter}`);
// Fetch resolver IPs and their statuses
const resolverIps = await page.$$eval('td[class="ip-address"]', ips => ips.map(ip => ip.innerText));
const resolverStatuses = await page.$$eval('td[data-ref^="resolverIp"]', statuses => statuses.map(status => status.innerText));
connectionInfo.resolverIps = resolverIps.map((ip, index) => ({
ip,
status: resolverStatuses[index]
}));
console.log(`Resolver IP Addresses:`);
connectionInfo.resolverIps.forEach(ipInfo => {
console.log(` - ${ipInfo.ip}: ${ipInfo.status}`);
});
await browser.close();
}
// Execute the function to fetch and log connection information
fetchConnectionInfo();