I wrote a script that changes the IP with stem, but it seems like it does not work. Here is a shortened version of the script:
from stem import Signal
from stem.control import Controller
from stem.connection import connect
def changeIP():
with Controller.from_port(port = 9051) as controller:
controller.authenticate()
controller.signal(Signal.NEWNYM)
def printIP():
my_ip = urlopen('http://ip.42.pl/raw').read()
print("IP -> %s" % my_ip)
#Some of my other codes
while(true):
j+=1
if j == 2:
changeIP()
j = 0
printIP()
And it just prints my public IP again and again. It should print the same IP 2 times and then change, but it doesn't. My torrc config is correctly configured.
ControlPort = 9051
HashedControlPassword 16:AD2DD67382E391D960F7E38F49A1AAB31479A0576222AB885C3CCFD70B
cookie authentication 1
I even tried putting the hashed Control password in the control.authenticate(password='AD2DD67382E391D960F7E38F49A1AAB31479A0576222AB885C3CCFD70B')
, but it still did not work, and I also want my script to not use it.
I have been searching for this weeks now, and I found out that I can use SocksiPy
module, but I can't do it.
Please recode my script, Thank you very much.