Fix proxy handling in WAStartupService preventing instance to be created

This commit is contained in:
Judson Junior 2024-01-21 13:01:35 -03:00
parent 1e9b3a1e42
commit 82e111f1be

View File

@ -1384,14 +1384,18 @@ export class WAStartupService {
this.logger.info('Proxy enabled: ' + this.localProxy.proxy);
if (this.localProxy.proxy.host.includes('proxyscrape')) {
const response = await axios.get(this.localProxy.proxy.host);
const text = response.data;
const proxyUrls = text.split('\r\n');
const rand = Math.floor(Math.random() * Math.floor(proxyUrls.length));
const proxyUrl = 'http://' + proxyUrls[rand];
options = {
agent: new ProxyAgent(proxyUrl as any),
};
try {
const response = await axios.get(this.localProxy.proxy.host);
const text = response.data;
const proxyUrls = text.split('\r\n');
const rand = Math.floor(Math.random() * Math.floor(proxyUrls.length));
const proxyUrl = 'http://' + proxyUrls[rand];
options = {
agent: new ProxyAgent(proxyUrl as any),
};
} catch (error) {
this.localProxy.enabled = false;
}
} else {
let proxyUri =
this.localProxy.proxy.protocol + '://' + this.localProxy.proxy.host + ':' + this.localProxy.proxy.port;