Fallback on codeberg for instance fetching
This commit is contained in:
parent
6ae9616bc7
commit
532e01b49f
|
@ -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()
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue