network-programmingproxytoranonymity

Different TOR IPs at http/https


I make requests over TOR to the same website but over different protocols: http://wtfismyip.com/text and https://wtfismyip.com/text

and sometimes get different exit IPs. Can anybody explain why is this so? Maybe some TOR relays does not support HTTPS and because of this the other relay becomes exit-node for https schema?


Solution

  • It is because something like "TOR keep-alive". It is remember the exit node you access the website from and tries to use it again after exit node change even. All is needed to fix this is to close the connection. Like the following:

    resp1 = sess.get('http://wtfismyip.com/text')
    ip1 = resp1.text
    
    change_node()
    resp1.connection.close()
    
    resp2 = sess.get('http://wtfismyip.com/text')
    ip2 = resp2.text
    

    After that the IPs are different.