javascript - Using the Tor api to make an anonymous proxy server -


i making app makes lots of api calls site. trouble i've run site has limit on number of api calls can made per minute. around hoping use tor in conjunction node-http-proxy create proxy table uses anonymous ip addresses taken tor api.

so question is, how possible this, , tools recommend getting done. app written in javascript, solutions involving things node-tor preferable.

i've found reasonable solution using tor , curl command line tools via node.js.

download tor command-line tool , set in $path.

now, can send requests through local tor proxy establish "circuit" through tor network. let's see our ip address using http://ifconfig.me. can copy paste of these things node repl:

var cp = require('child_process'),     exec = cp.exec,     spawn = cp.spawn,     tor = spawn('tor'),     puts = function(err,stdo,stde){ console.log(stdo) },     child; 

after this, may want build in delay while tor proxy spawned & sets up.

next, let's go through tor network , ask http://ifconfig.me ip address accessing it.

function sayip(){   child = exec('curl --proxy socks5h://localhost:9050 http://ifconfig.me',puts); }  sayip(); 

if want new ip address, restarting tor turning off , on seems reliable method:

function restarttor(){   tor.kill('sigint');   tor = spawn('tor'); }  restarttor(); 

note: there way i've seen people describe getting new ip address (setting new "circuit") on fly, seems work 10% of time in tests. if want try it:

find & copy torrc.sample torrc, change torrc follows:

  1. uncomment controlport 9051 (9050 local proxy, opening 9051 lets control it)
  2. uncomment & set cookieauthentication 0.
  3. uncomment hashedcontrolpassword , set result of:

    $ tor --hash-password "your_password"

then use function send newnym signal local tor proxy try getting new ip address without restarting.

function newip(){   var signal = 'echo -e "authenticate \"your_password\"\r\nsignal newnym\r\nquit" | nc -v 127.0.0.1 9051';   child = exec(signal,puts); }  newip(); 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -