Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
overtrue committed Nov 8, 2024
1 parent 37fb8ca commit d18be04
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
8 changes: 4 additions & 4 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class App {

if (this.retries > 2) {
console.error(`[ERROR] too many retries(${this.retries}), sleeping...`)
await sleep(getRandomInt(100, 6000))
await sleep(getRandomInt(10, 6000))
}

// Loop through each websocketUrl in case the other does not work
Expand Down Expand Up @@ -186,7 +186,7 @@ class App {
this.websocket.on('message', async function (message) {
console.log(`[REVEIVED] received message: ${chalk.blue(message)}`)

await sleep(getRandomInt(2, 80))
// await sleep(getRandomInt(0, 1))

// Update last live connection timestamp
this.lastLiveConnectionTimestamp = getUnixTimestamp()
Expand Down Expand Up @@ -218,7 +218,7 @@ class App {
break
case 'PONG':
result = {}
await sleep(getRandomInt(20, 120))
// await sleep(getRandomInt(0, 3))
break
default:
console.error(`[ERROR] No RPC action ${chalk.red(parsedMessage.action)}!`)
Expand Down Expand Up @@ -299,7 +299,7 @@ class App {
} catch (e) {
// Do nothing.
}
await sleep(getRandomInt(120, 2000))
await sleep(getRandomInt(2, 200))
this.initialize()
clearInterval(timer)
return
Expand Down
28 changes: 19 additions & 9 deletions start.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,28 @@ const USER = {
userAgent: randomUserAgent()
}

const PROXIES = fs.readFileSync('proxies.txt').toString().split('\n').map(proxy => proxy.trim()).filter(proxy => proxy)
let PROXIES = []

console.info(`[${USER_ID}] Starting with user with ${PROXIES.length} proxies...`)
try {
PROXIES = fs.readFileSync('proxies.txt').toString().split('\n').map(proxy => proxy.trim()).filter(proxy => proxy)
} catch (error) {
console.error('Failed to read proxies.txt', error)
}

async function main() {
const promises = PROXIES.map(async proxy => {
await sleep(getRandomInt(100, 6000))
console.info(`[${USER.id}] Starting with proxy ${proxy}...`)
await run(USER, proxy)
})

await Promise.all(promises)
if (PROXIES.length < 1) {
console.info(`[${USER.id}] Starting without proxy...`)
await run(USER)
} else {
console.info(`[${USER_ID}] Starting with user with ${PROXIES.length} proxies...`)
const promises = PROXIES.map(async proxy => {
await sleep(getRandomInt(100, 6000))
console.info(`[${USER.id}] Starting with proxy ${proxy}...`)
await run(USER, proxy)
})

await Promise.all(promises)
}
}

main().catch(console.error)

0 comments on commit d18be04

Please sign in to comment.