talmobi/tor-request

setTorAddress won't change TOR IP?

Closed this issue · 3 comments

It seems when using setTorAddress, the connection keeps attempting to connect to localhost.

I've been trying to connect to the IP of a Docker container, and the only way that seems to work is to mess with the index.js file and set the IP in createProxySettings such as
// set default proxy settings
var default_proxy_settings = createProxySettings("CONTAINER_IP", 9050);
and the host on TorControlPort such as
var TorControlPort = {
password: "", // password for ControlPort
host: 'DOCKER_IP',
...

This is a super hacky workaround to have the app run as needed, for now..
Any idea why setTorAddress doesn't change the TOR address?

Hi!

I just tested it and it should work -- did you reconfigure the module before issuing requests?

try this:

var tr = require( 'tor-request' )
tr.TorControlPort.host = 'DOCKER_IP'
tr.setTorAddress( 'CONTAINER_IP', 9050 )

// ready to make requests
tr.request( 'http://ip-spot.com', function ( err, res, body ) {
  console.log( body )
} )

Hey!

Hadn't realised I needed to also do tr.TorControlPort.host = 'DOCKER_IP'.

Works like a charm, thanks!

Yeah the API isn't ideal :/ haven't had any time to revisit this project for a long time.

Glad you got it working!