Is there some easy method to use circuits in parallel in TOR using the STEM API. I wanted to use Website A for Circuit A and Website B for Circuit B. The problem is using threading the event listener is global hence both threads attach streams for both websites on each circuit.
This (attached below) is the function I'm calling in each thread:
def scan(controller, path, websites, numReadings):
circuit_id = controller.new_circuit(path, await_build = True)
def attach_stream(stream):
if stream.status == 'NEW':
try:
controller.attach_stream(stream.id, circuit_id)
except Exception as E:
print "Scan: " + str(E)
return 1000
controller.add_event_listener(attach_stream, stem.control.EventType.STREAM)
try:
controller.set_conf('__LeaveStreamsUnattached', '1') # leave stream management to us
getPage(controller, websites, numReadings, path)
finally:
controller.remove_event_listener(attach_stream)
controller.reset_conf('__LeaveStreamsUnattached')
controller.close_circuit(circuit_id)
target
in StreamEvent over here: stem.torproject.org/api/… – QPTR Aug 21 '16 at 17:04stream.target
insideattach_stream
to check the website's address that the stream belongs to, and then attach that stream to the circuit you want. Or at least thats what I think. Could be wrong. – QPTR Aug 22 '16 at 15:03