talmobi/tor-request

Refresh session for the specific port

SashaDesigN opened this issue · 4 comments

Hi, I just had read all issues to be sure that not asking twice the same question.

I set up a few ports on my torrc

SocksPort 9050
SocksPort 9052
SocksPort 9053
SocksPort 9054
ControlPort 9051
HashedControlPassword 16:mypass

And my NodeJS app runs 4 instances and use pre-defined port, For ex. app 1 - 9050, app 2 - 9052 and e.g.

What I want to achieve:
instances work 1min and after need to refresh the IP on the instance's port before restart.

So is there a way to refresh session for the specific port using tr.renewTorSession?

As I see so far, there no, so to make it work need to add Docker in the game and run 4 containers with TOR client inside.

Thanks for advice.

Halåj,

You are correct. Docker might work for you. This library is just a tiny helper to connect to the Tor Client; and in your first example you are only running 1 Tor Client (but 4 Node.JS and what I assume 4 open ports to the Tor Client) clients.

I am not sure if the Tor Client itself can do what you want. It perhaps can, I'm not sure. (docs here: https://2019.www.torproject.org/docs/documentation.html.en)

But a docker container should do the trick as that would also instantiate a branch new Tor Client for each to handle the connections, so that should work and is what I'd recommend.

Also note that tr.renewTorSession is not the only way to renew ip address, another way is to simply kill and restart the Tor Client itself -- that kind of actually suggest that the Tor Client can only handle as a single IP at a time so that's more evidence you would have to use something like Docker.

Also another thing: The Tor Client might renew its IP by itself randomly from time to time. This happens for many reasons. Exit nodes change etc. Just something to be aware of.

Oh ok, thanks for some complex answer)
And randomly IPs renewal isn't a bad thing for my app