[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [tor-relays] How do I get the *current* Tor exit node IP address over the control port?



Hi Matt,

On Mon, 27 Jan 2020 08:56:32 -0500 Matt Traudt wrote:

> stem's get_circuits() function on a controller.
> 
> https://stem.torproject.org/api/control.html#stem.control.Controller.get_circuits
> 
> You'll get a list of circuit objects, which each have a path. For each
> circuit that is built for the purpose of carrying your traffic to a
> non-onion destination, the last item in the path is an exit node.

Thanks for the reply.

The reference to get_circuits seems to imply the first answer linked in
my S.O. question - a short python code which lists all circuits:

https://stackoverflow.com/a/17130011

To get the IP address of the current Tor exit node (the one which would
be used if I attempt a connection to a non-onion destination) I use one
of these:

(1) torsocks curl https://ipinfo.io/ip
(2) torsocks dig @resolver1.opendns.com ANY myip.opendns.com +short

Both these commands give the same IP address but it is the same as the
last one listed by python script given above (which uses get_curcuits).
Am I doing something wrong?

> It's all in the stem documentation. I would familiarize yourself with
> it.

I am trying to but as I am still new to Python, so it is still beyond
my level.

> Also, this is a mailing list for Tor relay operators to talk about
> relay operation stuff. tor-talk@ might have been a better place for this.

It is the first time I use these lists, so please forgive me. Should I
stop posting here instantly and re-post the original question to
tor-talk?

> Note your misconception that there is only **one** circuit or **one**
> exit at a time. Not true. Tor may choose to open new circuits for a wide
> variety of reasons. The remainder of this email is a copy/paste response
> I use on Reddit when people seem to have this misconception.

Perhaps if I should have clarified my global goal:

I want to be able to receive a new **different** IP address for
different connections which a bash script makes. Suppose (simplified):

----------
#!/bin/bash

torsocks curl http://site1.com
get-new-tor-ip
torsocks curl http://site2.com
get-new-tor-ip
...
----------

Currently I get-new-tor-ip like this (simplified):

----------
oldip=$(torsocks dig @resolver1.opendns.com ANY myip.opendns.com +short)
newip="${oldip}"
while [ "${newip}" == "${oldip}" ]
do
    newip= ... # As described in http://vt5hknv6sblkgf22.onion/faq.html#how-do-i-request-a-new-identity-from-tor
done
----------

I am willing to avoid the call to an external service.

I understand the rest of your explanations but I am afraid I am not
clever enough to find the answer to my goal in them.

Can you help?

Again: if it is inappropriate to ask here, I can repeat the question in
tor-talks. Just let me know please. Thanks.
_______________________________________________
tor-relays mailing list
tor-relays@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-relays