3

I have a Python script that is configured to connect to 4 different onion services (call them a, b, c, d), and return a value on a page. I'd like to ensure that I create separate circuits to connect to each so that circuit-1 only connects to a and is never used for b,c, or d.

I'm using Stem and this is an example they provide for issuing a NEWNYM command to the control protocol and create new circuits.

    with Controller.from_port(port = 9150) as controller:
        controller.authenticate()
        controller.signal(Signal.NEWNYM)

I understand this to flush all circuits and re-build new ones.

Is there a better way to specifically control which circuit a Python HTTP request takes? I'd like concurrently make these requests from 4 different circuits at the same time. Basically:

  • create new circuit
  • assign circuit to a.onion
  • issue request
  • destroy circuit
  • repeat for b, c, and d.onion
3

Nice timing, we just expanded our tutorials around this! For this you should use new_circuit() and attach_stream() rather than NEWNYM. For an example of doing this see...

https://stem.torproject.org/tutorials/to_russia_with_love.html#custom-path-selection

  • Don't think there could be a better answer. Thanks! – Lizbeth Jun 4 '15 at 19:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.