Fallback on codeberg for instance fetching

This commit is contained in:
BobIsMyManager 2022-07-27 19:17:50 +01:00
parent 6ae9616bc7
commit 532e01b49f
1 changed files with 52 additions and 44 deletions

View File

@ -40,9 +40,19 @@ async function initcloudflareBlackList() {
function updateInstances() {
return new Promise(async resolve => {
let http = new XMLHttpRequest()
let fallback = new XMLHttpRequest()
http.open("GET", "https://raw.githubusercontent.com/libredirect/libredirect/master/src/instances/data.json", false)
http.send(null)
if (http.status === 200) {
if (http.status != 200) {
fallback.open("GET", "https://codeberg.org/LibRedirect/libredirect/raw/branch/master/src/instances/data.json", false)
fallback.send(null)
if (fallback.status === 200) {
http = fallback
} else {
resolve()
return
}
}
await initcloudflareBlackList()
const instances = JSON.parse(http.responseText)
@ -85,8 +95,6 @@ function updateInstances() {
console.info("Successfully updated Instances")
resolve(true)
return
}
resolve()
})
}