deedy5 / requests_tor

Multithreading requests via TOR with automatic TOR new identity
MIT License
53 stars 15 forks source link

added support for specifying Tor service host IP address #15

Open david-pettifor-nd opened 1 year ago

david-pettifor-nd commented 1 year ago

Added optional parameter for specifying a host IP address, should the Tor service be running on a different host (defaults to 127.0.0.1). This IP address should not be a host name, as it is also used for the Controller class, which requires a valid IP address.

HS-157 commented 1 year ago

You should change 127.0.0.1 to localhost in case the TOR service is running in IPv6.

david-pettifor-nd commented 1 year ago

In testing, the TOR Controller library used in stem failed to recognize localhost as a valid IP address (see: https://github.com/torproject/stem/blob/master/stem/control.py#L1077C123-L1077C123) because the host address passed in apparently needs to be valid for both IPv4 and IPv6. I would also like to see the Controller accept hostnames rather than requiring IP addresses as this would make it easier for docker deployment.

HS-157 commented 1 year ago

Oh ! I didn't see this problem with the method parameter. There is a issue for this : https://github.com/torproject/stem/issues/116 Thank you.

deedy5 commented 1 year ago

https://github.com/deedy5/requests_tor#advanced-usage https://2019.www.torproject.org/docs/tor-manual.html.en#ControlPort https://2019.www.torproject.org/docs/tor-manual.html.en#HashedControlPassword If you need to connect to a remote ip, you must specify password for the new_id() function to work.

This password must be generated and added to the torrc file on the remote host to which you want to connect.

So we should also add a check that if tor_host != '127.0.0.1' then password cannot be None (and correct the Readme accordingly).