Use dotapps proxy

This commit is contained in:
Jaco Greeff
2021-02-18 12:36:17 +01:00
parent 0122d36bf5
commit 551e9f7740
+8 -45
View File
@@ -192,53 +192,16 @@
return response; return response;
} }
function checkUpCors (url, { contents, status: { content_length, error } }) {
// has an error from the CORS proxy
if (
error &&
(error.code !== 'UNABLE_TO_VERIFY_LEAF_SIGNATURE')
) {
console.log(`${url} has an retrieval error`)
return false;
}
// has actual content or it has a refresh
if (
(content_length < 100) &&
!contents.includes('<meta http-equiv="refresh"')
) {
console.log(`${url} has no content`);
return false;
}
// include in inactive list when the provider has suspended the account
if (
contents.includes('This Account has been suspended') ||
contents.includes('Хостинг сайта временно приостановлен')
) {
console.log(`${url} has been suspended`)
return false;
}
return true;
}
async function isUp (url) { async function isUp (url) {
fetchTimeout(`https://proxy.dotapps.workers.dev/?url=${encodeURIComponent(url)}`) try {
.then((response) => console.log(url, response)) await fetchTimeout(url, { method: 'HEAD', mode: 'no-cors' });
.catch((error) => console.error(url, error));
return fetchTimeout(url, { method: 'HEAD', mode: 'no-cors' }) const response = await fetchTimeout(`https://proxy.dotapps.workers.dev/?${url}`, { follow: 'error' });
.then(() =>
fetchTimeout(`https://api.allorigins.win/get?url=${encodeURIComponent(url)}`) return response.status === 200;
.then((response) => response.json()) } catch (error) {
.then((json) => checkUpCors(url, json)) return false;
.catch(() => true) }
)
.catch(() => false);
} }
async function getBalance (key) { async function getBalance (key) {