Skip to content

Commit

Permalink
Merge pull request #5 from vfarid/dev
Browse files Browse the repository at this point in the history
Update index.html
  • Loading branch information
vfarid authored Mar 15, 2023
2 parents 3860791 + 169108f commit 1dd715b
Showing 1 changed file with 153 additions and 30 deletions.
183 changes: 153 additions & 30 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
<table>
<thead>
<tr>
<th width="200">IP</th>
<th width="180">IP</th>
<th width="90">Location</th>
<th width="70">Time</th>
</tr>
</thead>
Expand All @@ -25,45 +26,167 @@
<script type="text/javascript">
// Version 1.1

const cfIPv4 = [
'173.245.48.0/20',
'103.21.244.0/22',
'103.22.200.0/22',
'103.31.4.0/22',
'141.101.64.0/18',
'108.162.192.0/18',
'190.93.240.0/20',
'188.114.96.0/20',
'197.234.240.0/22',
'198.41.128.0/17',
'162.158.0.0/15',
'104.16.0.0/13',
'104.24.0.0/14',
'172.64.0.0/13',
'131.0.72.0/22'
];
const cfIPv4 = {
London: [
'45.8.104.0/29',
'185.207.92.0/24',
'185.193.28.0/23',
'185.193.30.0/23',
'203.17.126.0/24',
'207.189.149.0/24',
'89.47.56.0/23',
'93.114.64.0/23',
'176.126.206.0/23',
'203.23.103.0/24',
'203.24.102.0/24',
'203.24.103.0/24',
'203.24.109.0/24',
'203.29.52.0/24',
'203.29.54.0/23',
'203.30.188.0/22',
'203.32.120.0/23',
'203.34.28.0/24',
'203.34.80.0/24',
'203.55.107.0/24',
'185.162.228.0/23',
'185.162.230.0/23',
'203.13.32.0/24',
'203.22.223.0/24',
'203.23.104.0/24',
'203.23.106.0/24',
'203.24.108.0/24',
'203.28.8.0/24',
'203.28.9.0/24',
'203.29.53.0/24',
'141.193.213.0/24',
'185.201.139.0/24',
'199.60.103.0/24',
'12.221.133.0/24',
'203.107.173.0/24',
'195.245.221.0/24',
'212.110.134.0/23',
'45.14.174.0/24',
'194.169.194.0/24',
'185.109.21.0/24',
'185.170.166.0/24',
'191.101.251.0/24',
'45.12.30.0/23',
'45.85.118.0/23',
'103.156.22.0/23',
'194.152.44.0/24',
'45.131.4.0/22',
'45.131.208.0/22',
'103.160.204.0/24',
'45.133.247.0/24',
'185.174.138.0/24',
'185.221.160.0/24',
'194.53.53.0/24',
'195.85.23.0/24',
'154.83.22.0/23',
'154.83.30.0/23',
'154.84.14.0/23',
'154.84.16.0/21',
'154.84.24.0/22',
'154.85.8.0/22',
'154.94.8.0/23',
'154.219.2.0/23',
'156.237.4.0/23',
'156.238.14.0/23',
'156.238.18.0/23',
'156.239.152.0/22',
'195.85.59.0/24',
'31.43.179.0/24',
'185.72.49.0/24',
'194.40.240.0/24',
'104.254.140.0/24',
'103.244.116.0/22',
'185.238.228.0/24',
'199.181.197.0/24',
'91.193.58.0/23',
'108.165.216.0/24',
'147.78.140.0/24',
'154.83.2.0/24',
'193.16.63.0/24',
'195.137.167.0/24',
'45.142.120.0/24',
'204.68.111.0/24',
'174.136.134.0/24',
'193.188.14.0/24',
'196.207.45.0/24',
'194.40.241.0/24',
'194.36.55.0/24',
'103.169.142.0/24',
'147.185.161.0/24',
'208.100.60.0/24',
'45.8.211.0/24',
'194.36.49.0/24',
'80.94.83.0/24',
'45.145.28.0/24',
'45.145.29.0/24',
'89.207.18.0/24',
'194.1.194.0/24',
'5.226.179.0/24',
'203.193.21.0/24',
'204.62.141.0/24',
'185.146.172.0/24',
'23.227.37.0/24',
'185.146.173.0/24',
'141.101.100.0/24',
'23.227.60.0/24',
'103.81.228.0/24',
'198.217.251.0/24',
'190.93.244.0/22',
'190.93.240.0/20',
'64.68.192.0/24',
'23.227.38.0/23'
],
Worldwide: [
'173.245.48.0/20',
'103.21.244.0/22',
'103.22.200.0/22',
'103.31.4.0/22',
'141.101.64.0/18',
'108.162.192.0/18',
'190.93.240.0/20',
'188.114.96.0/20',
'197.234.240.0/22',
'198.41.128.0/17',
'162.158.0.0/15',
'104.16.0.0/13',
'104.24.0.0/14',
'172.64.0.0/13',
'131.0.72.0/22'
]
};

const urlParams = new URLSearchParams(window.location.search);

var maxIP = urlParams.get('max')
let maxIP = urlParams.get('max')
let testNo = 0;
let validIPs = [];

if (maxIP === null) {
maxIP = 20
} else {
maxIP = parseInt(maxIP);
}

var ips = [];
for (var cidr of cfIPv4) {
ips = ips.concat(cidrToIpArray(cidr));
var ips;
var cidr;
let numberOfWorkingIPs = 0;

for (var cdnLocation in cfIPv4) {
if (maxIP == 0 || numberOfWorkingIPs < maxIP) {
ips = [];
for (cidr of cfIPv4[cdnLocation]) {
ips = ips.concat(cidrToIpArray(cidr));
}
testIPs(randomizeElements(ips), cdnLocation);
}
}
testIPs(randomizeElements(ips), maxIP)

async function testIPs(ipList, maxIP) {
const timeout = 2000;
var testNo = 0;
var numberOfWorkingIPs = 0;
var validIPs = [];
async function testIPs(ipList, cdnLocation) {
const timeout = 2500;
for (const ip of ipList) {
testNo++;
var testResult = 0;
Expand Down Expand Up @@ -100,9 +223,9 @@

if (testResult === 5) {
numberOfWorkingIPs++;
validIPs.push({ip: ip, time: Math.floor(duration / 10) / 100});
validIPs.push({ip: ip, location: cdnLocation, time: Math.floor(duration / 5)});
const sortedArr = validIPs.sort((a, b) => a.time - b.time);
const tableRows = sortedArr.map(obj => `<tr><td>${obj.ip}</td><td>${obj.time}</td><tr>`).join('\n');
const tableRows = sortedArr.map(obj => `<tr><td>${obj.ip}</td><td>${obj.location}</td><td>${obj.time}</td><tr>`).join('\n');
document.getElementById('result').innerHTML = tableRows;
}

Expand Down

2 comments on commit 1dd715b

@ostadsalam43
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

index.html

@ostadsalam43
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.