Closed hassanila closed 8 years ago
Thanks, actually you can pretty easily do it with Bluebird, no need for another dependency.
var Promise = require('bluebird');
var fs = require('fs');
var checkProxy = require('check-proxy').check;
var proxies = [], workingProxies = [];
//Assume that each line contains new ip:port pair
fs.readFile('proxies.txt', function(err, data) {
if(err) throw err;
Promise.map(data.toString().trim().split("\n"), function(proxy, i) { // split by new line
var proxy = proxy.trim().split(':'); // get ip:pair into array
return checkProxy({
testHost: 'ping.rhcloud.com',
proxyIP: proxy[0],
proxyPort: proxy[1],
localIP: '1.1.27.23'
}).then(function(res) { // resolved
console.log('found working proxy', res);
workingProxies.push(res);
}, function(err) { // rejected for some reason
console.log('rejected', i, proxy[0], ':', proxy[1], err);
});
}, {concurrency: 5}) // 5 proxy checks at once, that's your 'maxThreadAmount'
.then(function() { // when all done
console.log('all done, found', workingProxies.length);
fs.writeFileSync('working-proxies.json', JSON.stringify(workingProxies));
process.exit();
});
});
ok nice. Thx
Is this possible with SOCKS proxies? Because now if I try to check a list with socks proxies I get always invalid (but I know the proxies work because if I try them in an other checker thy work)
This is an improvement request.
Can we make it able to get a txt file and* check all proxies* then return all information. The connections should be simulateous and we should be able to have a\ maxThreadAmount option [THIS**](https://github.com/ahmadnassri/ip-port-regex) will pase the proxies in objects from the txt file... Great work btw