-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
27 lines (25 loc) · 949 Bytes
/
index.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
let config = require('./config.json');
let fs = require('fs');
let cp = require('child_process');
let proxies = fs.readFileSync(config.proxyFile).toString().split('\n');
proxies.forEach(proxy => {
let timeBeforeChecking = new Date().getTime();
proxyRequest(config.testurl , `${config.proxyType}://${proxy}`)
.then(body => {
let currentTime = new Date().getTime();
console.log(`[+] ${proxy}\n =>${(currentTime-timeBeforeChecking).toString()}ms`)
cp.exec(`echo ${proxy} >> ${config.outputFile}`)
})
.catch(e => {
console.log(`[-] ${proxy}`)
cp.exec(`echo ${proxy} >> ${config.errorFile}`)
})
})
function proxyRequest(url , proxy) {
return new Promise((resolve , reject) => {
cp.exec(`curl "${url}" --proxy "${proxy}"` , (error , stdout , stderr) => {
if (error) return reject(stderr);
resolve(stdout)
})
})
}