ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ 2017-09-25 18:48:50 +03:00 committed by GitHub
parent 662ed78410
commit 2aa9cc1496
1 changed files with 69 additions and 0 deletions

69
index.html Normal file
View File

@ -0,0 +1,69 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h1>Public IPFS Gateways</h1>
<h3 id='stats'></h3>
</body>
<script>
const gateways = [
'https://ipfs.io/ipfs/:hash',
'https://gateway.ipfs.io/ipfs/:hash',
'https://ipfs.infura.io/ipfs/:hash',
'http://rx14.co.uk/ipfs/:hash',
'https://xmine128.tk/ipfs/:hash',
'https://upload.global/ipfs/:hash',
'https://ipfs.jes.xxx/ipfs/:hash',
'https://example.com/ipfs/:hash',
'https://catalunya.network/ipfs/:hash',
'https://siderus.io/ipfs/:hash',
'https://eternum.io/ipfs/:hash',
'https://hardbin.com/ipfs/:hash'
]
const hashToTest = 'Qmaisz6NMhDB51cCvNWa1GMS7LU1pAxdF4Ld6Ft9kZEP2a'
const hashString = 'Hello from IPFS Gateway Checker'
function addNode (gateway, online, title) {
const para = document.createElement('div')
let node
if (online) {
node = document.createElement('strong')
node.innerText = '✅ - Online - ' + gateway
} else {
node = document.createElement('div')
node.innerText = '❌ - Offline - ' + gateway
}
node.setAttribute('title', title)
para.appendChild(node)
document.body.appendChild(para)
}
function updateStats (total, checked) {
document.getElementById('stats').innerText = checked + '/' + total + ' gateways checked'
}
const total = gateways.length
let checked = 0
gateways.forEach((gateway) => {
const gatewayAndHash = gateway.replace(':hash', hashToTest)
fetch(gatewayAndHash)
.then(res => res.text())
.then((text) => {
const matched = text.trim() === hashString.trim()
addNode(gatewayAndHash, matched, matched ? 'All good' : 'Output did not match expected output')
checked++
updateStats(total, checked)
}).catch((err) => {
window.err = err
addNode(gatewayAndHash, false, err)
checked++
updateStats(total, checked)
})
})
</script>
</html>