torpyorg / torpy

Pure python Tor client implementation
Apache License 2.0
403 stars 48 forks source link

Possible to programmatically start/stop socks5 proxy circuit? #11

Closed iblind closed 3 years ago

iblind commented 3 years ago

First off, I'm not very familiar with networking concepts, so apologies in advance if I butcher something.

I'm attempting to set up a socks5 proxy for making programmatic requests to a particular server. Now, I understand that I can have one terminal window where I locally type torpy_socks -p 1050 --hops 3 in order to create a new circuit, and then indicate the proxy list thus:

  1. proxies_list = { 'http': 'socks5://user:pass@127.0.0.1:1050', 'https': 'socks5://user:pass@127.0.0.1:1050' }

  2. requests.get("http://httpbin.org/ip", proxies= proxies_list)

I'm wondering, however, if it's possible to set up a fresh circuit (i.e., essentially run torpy_socks -p 1050 --hops 3 again after killing the initial circuit) programmatically, if a particular condition is met (e.g., if a counter reaches 5).

Again, sorry if this was phrased poorly, but hopefully it's made sense so far!

Edit: I've understood that executing command line commands using os.system('some_code') would work to create the circuit initially, but I'd like to know if it's possible to kill and restart that particular process from within the same script.

jbrown299 commented 3 years ago

Sorry, I will close this issue because it is not about torpy project. You need to implement what you like to do byself.