256cats / check-proxy

Advanced Node proxy checker (node proxy verifier, node proxy tester) with socks and https support
https://www.npmjs.com/package/check-proxy
MIT License
107 stars 40 forks source link

Simultaneous check (proxylist) #1

Closed hassanila closed 8 years ago

hassanila commented 8 years ago

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

256cats commented 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();
  });
});
hassanila commented 8 years ago

ok nice. Thx

J0113 commented 7 years ago

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)