Advertisement
Guest User

Untitled

a guest
May 29th, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. #!/usr/bin/nodejs
  2. var express=require('express');
  3. var proxyChecker=require('proxy-checker');
  4. var async=require('async');
  5. var app = express();
  6. var fs = require('fs');
  7. var util = require('util');
  8. var debug=true;
  9. var callbackMap=[];
  10. var limit=10;//How many proxies can be tested at any given time
  11.  
  12. global.setImmediate = global.setImmediate || process.nextTick.bind(process); //F ix for bug in express
  13.  
  14. app.get('/', function(req,res) {
  15. if (req.query.ip) {
  16. var ident = req.query.ip+':'+req.query.port;
  17. options = {
  18. url:'http://www.danmorgan.net',
  19. regex: /Dan/
  20. }
  21. callbackMap[ident] = req.query.callback;
  22. console.log('A');
  23. async.parallelLimit([
  24. function(){
  25. console.log('C');
  26. /*
  27. proxyChecker.checkProxy(
  28. res.query.ip,
  29. res.query.port,
  30. options,
  31. function (host,port,ok,statusCode,err) {
  32. var ident = host+':'+port;
  33. delete callbackMap[ident];
  34. }
  35. );
  36. */
  37. }
  38. ],limit);
  39. console.log('B');
  40. res.send(JSON.stringify({'ok':true}));
  41. } else {
  42. console.log('not trying.');
  43. res.send(JSON.stringify({'ok':false}));
  44. }
  45. });
  46.  
  47. var server = app.listen(3000, function() {
  48. var host = server.address().address;
  49. var port = server.address().port;
  50. console.log('Server listening on %s:%s',host,port);
  51. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement