hfreire/request-on-steroids

Refresh the Tor session (i.e., get a new proxy IP address) without restarting your Tor client

Opened this issue · 3 comments

pbar1 commented

What's the status on this? As it stands right now, would you need to manually restart your Tor client?

Hi @pbar1, you would need to restart your Tor client, or at least, depending on the purpose, you would configure the Tor client accordingly in the Tor client configuration file, i.e. refresh the tor exit node so you get a new IP address.

There is a way to accomplish this programmatically in a clean way as @talmobi is doing. It shouldn't be difficult, I just hadn't had the time yet. If you feel like, you are welcome to push a pull request.

Halåj,

The easiest way to refresh the Tor session is probably to restart the tor process, although perhaps not ideal.

The other way requires an additional - manual - step to setup and configure your tor config file. You need to enable the ControlPort ( basically uncomment a line in your tor configuration file ) and generate/add the HashedControlPort password using tor --hash-password PASSWORD to the configuration file as well.

Then, whenever you want to refresh the tor session, you can open up a TCP connection to the ControlPort port ( 9051 by default ) and send a text based commands based on the tor control specification: https://gitweb.torproject.org/torspec.git/tree/control-spec.txt

Basically sending the NEWNYM signal ( after you have authenticated with AUTHENTICATE "PASSWORD" )

NEWNYM    -- Switch to clean circuits, so new application requests
                   don't share any circuits with old ones.  Also clears
                   the client-side DNS cache.  (Tor MAY rate-limit its
                   response to this signal.)

ControlPort configuration guide

https://github.com/talmobi/tor-request#optional-configuring-tor-enabling-the-controlport

TCP connection to ControlPort

https://github.com/talmobi/tor-request/blob/master/index.js#L134-L157

Authenticating and sending NEWNYM signal to ControlPort

https://github.com/talmobi/tor-request/blob/master/index.js#L164-L191