fix hero
This commit is contained in:
parent
3b4aa6c8f0
commit
6ef3b1fe6d
31
index.ts
31
index.ts
|
@ -149,11 +149,18 @@ const farm: () => Promise<void> = async () => {
|
||||||
logger.info(`Current worker:${worker.phoneNumber}\nBalance:${worker.balance}`);
|
logger.info(`Current worker:${worker.phoneNumber}\nBalance:${worker.balance}`);
|
||||||
|
|
||||||
{
|
{
|
||||||
const torConnection = await connect({
|
let torConnection: any
|
||||||
host: '127.0.0.1',
|
try{
|
||||||
port: ports.control,
|
torConnection= await connect({
|
||||||
password: 'qwerty',
|
host: '127.0.0.1',
|
||||||
});
|
port: ports.control,
|
||||||
|
password: 'qwerty',
|
||||||
|
});
|
||||||
|
} catch( err){
|
||||||
|
logger.error(`Cant connect to tor control via ${ports.control}\n${err}`)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
function isFree(currentIP: string) {
|
function isFree(currentIP: string) {
|
||||||
for (const usedIP of usedIPs) {
|
for (const usedIP of usedIPs) {
|
||||||
|
|
||||||
|
@ -198,6 +205,10 @@ const farm: () => Promise<void> = async () => {
|
||||||
viewport: fingerprint.screen,
|
viewport: fingerprint.screen,
|
||||||
locale: fingerprint.navigator.language,
|
locale: fingerprint.navigator.language,
|
||||||
upstreamProxyUrl: `socks5://127.0.0.1:${ports.socks}`,
|
upstreamProxyUrl: `socks5://127.0.0.1:${ports.socks}`,
|
||||||
|
upstreamProxyIpMask:{
|
||||||
|
ipLookupService:'icanhazip.com',
|
||||||
|
proxyIp:usedIPs.filter((value) => { return _.isEqual(worker, value.worker) })[0].current
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
hero.use(ExecuteJsPlugin);
|
hero.use(ExecuteJsPlugin);
|
||||||
|
@ -401,10 +412,12 @@ const farm: () => Promise<void> = async () => {
|
||||||
logger.warn(`There is strange thing with workersGroups\n${workersGroups.length} ${Math.ceil(workers.length / settings.pararels)}`);
|
logger.warn(`There is strange thing with workersGroups\n${workersGroups.length} ${Math.ceil(workers.length / settings.pararels)}`);
|
||||||
}
|
}
|
||||||
let pararels: Promise<void>[] = [];
|
let pararels: Promise<void>[] = [];
|
||||||
let _ports = await findFreePorts(workers.length * 3 + 1);
|
|
||||||
const miner = new Miner();
|
const miner = new Miner();
|
||||||
await miner.listen({ port: _ports[_ports.length - 1] });
|
await miner.listen();
|
||||||
|
|
||||||
|
const _ports = await findFreePorts(workers.length * 3);
|
||||||
|
logger.debug(`Is there port of miner:${_ports.indexOf(await miner.port)}, ${await miner.port}`)
|
||||||
let containers: Docker.Container[] = [];
|
let containers: Docker.Container[] = [];
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -444,7 +457,7 @@ const farm: () => Promise<void> = async () => {
|
||||||
const results = await Promise.allSettled(pararels);
|
const results = await Promise.allSettled(pararels);
|
||||||
for (const result of results) {
|
for (const result of results) {
|
||||||
if (result.status == 'rejected') {
|
if (result.status == 'rejected') {
|
||||||
logger.warn(`Promise is caanceled due ${result.reason}`);
|
logger.warn(`Promise is canceled due ${result.reason}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger.debug('Closing opened docker containers ')
|
logger.debug('Closing opened docker containers ')
|
||||||
|
@ -456,7 +469,7 @@ const farm: () => Promise<void> = async () => {
|
||||||
|
|
||||||
}
|
}
|
||||||
await db.save()
|
await db.save()
|
||||||
await miner.close(true);
|
// await miner.close(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// menu
|
// menu
|
||||||
|
|
Loading…
Reference in a new issue