2

Specs (MacOSx - Last version , Python 3.5 , Stem and Tor Browser for Mac)

I just start to learn more about Tor and i wanted to change my Tor route from Python Script.

from stem import Signal
from stem.control import Controller
from stem import CircStatus

def getIP():
    with Controller.from_port(port = 9151) as controller:
        controller.authenticate()
        for circ in controller.get_circuits():
            if circ.status != CircStatus.BUILT:
                continue

            exit_fp, exit_nickname = circ.path[-1]

            exit_desc = controller.get_network_status(exit_fp, None)
            exit_address = exit_desc.address if exit_desc else 'unknown'

            print ("Exit relay")
            print ("  fingerprint: %s" % exit_fp)
            print ("  nickname: %s" % exit_nickname)
            print ("  address: %s" % exit_address)

def newIP():
    with Controller.from_port(port = 9151) as controller:
        controller.authenticate()
        controller.signal(Signal.NEWNYM)
        print("\n\nNEW IP, NEW IP\n\n")

getIP()
newIP()
getIP()

But the above code doesn't negociate a new ip between the two getIP(). I checked that the connection was right :

telnet localhost 9151
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

Could you help me to understand why can't i do it ?

Regards,

Jérémy.

Jérémy JOKE
  • 271
  • 4
  • 15

0 Answers0