[addon] refreshes and blacklists failed proxies

This commit is contained in:
TheBeastLT
2020-06-06 16:18:41 +02:00
parent 0361dc8096
commit 6496d7785e
3 changed files with 31 additions and 11 deletions

View File

@@ -17,4 +17,12 @@ function getRandomProxy() {
return undefined;
}
module.exports = { getRandomUserAgent, getRandomProxy };
function blacklistProxy(proxy) {
const proxyHost = proxy.replace(/.*@/, '');
console.warn(`Blacklisting ${proxyHost}`);
if (PROXY_HOSTS && PROXY_HOSTS.indexOf(proxyHost) > -1) {
PROXY_HOSTS.splice(PROXY_HOSTS.indexOf(proxyHost), 1);
}
}
module.exports = { getRandomUserAgent, getRandomProxy, blacklistProxy };