Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/nodejs
- var express=require('express');
- var proxyChecker=require('proxy-checker');
- var async=require('async');
- var app = express();
- var fs = require('fs');
- var util = require('util');
- var debug=true;
- var callbackMap=[];
- var limit=10;//How many proxies can be tested at any given time
- global.setImmediate = global.setImmediate || process.nextTick.bind(process); //F ix for bug in express
- app.get('/', function(req,res) {
- if (req.query.ip) {
- var ident = req.query.ip+':'+req.query.port;
- options = {
- url:'http://www.danmorgan.net',
- regex: /Dan/
- }
- callbackMap[ident] = req.query.callback;
- console.log('A');
- async.parallelLimit([
- function(){
- console.log('C');
- /*
- proxyChecker.checkProxy(
- res.query.ip,
- res.query.port,
- options,
- function (host,port,ok,statusCode,err) {
- var ident = host+':'+port;
- delete callbackMap[ident];
- }
- );
- */
- }
- ],limit);
- console.log('B');
- res.send(JSON.stringify({'ok':true}));
- } else {
- console.log('not trying.');
- res.send(JSON.stringify({'ok':false}));
- }
- });
- var server = app.listen(3000, function() {
- var host = server.address().address;
- var port = server.address().port;
- console.log('Server listening on %s:%s',host,port);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement