-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstart.js
36 lines (27 loc) · 876 Bytes
/
start.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import consoleStamp from 'console-stamp'
import fs from 'fs'
import { run } from './app.js'
import { getRandomInt, randomUserAgent, sleep } from './utils.js'
consoleStamp(console, {
format: ':date(yyyy/mm/dd HH:MM:ss.l)'
})
const USER_ID = process.env.USER_ID
if (!USER_ID) {
console.error('USER_ID not set')
process.exit(1)
}
const USER = {
id: USER_ID,
userAgent: randomUserAgent()
}
const PROXIES = fs.readFileSync('proxies.txt').toString().split('\n').map(proxy => proxy.trim()).filter(proxy => proxy)
console.info(`[${USER_ID}] Starting with user with ${PROXIES.length} proxies...`)
async function main() {
const promises = PROXIES.map(async proxy => {
await sleep(getRandomInt(10, 6000))
console.info(`[${USER.id}] Starting with proxy ${proxy}...`)
await run(USER, proxy)
})
await Promise.all(promises)
}
main().catch(console.error)