Hi guys, I have quite special question. As I wrote many times before, Im trying to do some utility in python using Tor. Currently, Im playing again with core of utility - talking with Tor and downloading some files thru it.<br>
<br>Im trying to download HTTP file thru exact path (defined by router chain). So I tried to make these steps:<br>1) Create circuit<br>2) Create stream<br>3) Attach stream to circuit<br>4) Do HTTP communication<br><br>Are these steps logically OK? Because if yes, Im in problematic situation. When I tried to openstream with __LeaveStreamsUnattached=0 (default configuration), Tor automatically assign stream to any open circuit (but I want to use one specific). But when I set __LeaveStreamsUnattached=1, I obtain deadlock on &quot;proxy.connect()&quot; and I cannot continue with point 3). But I dont found any method, how to obtain stream id _before_ calling proxy.connect() to pair stream to circuit before calling this function...<br>
<br>Please tell me, what I should do different, because I think I tried everything :). Yes, I can connect specific circuit with specific stream (using REMAP), but this solution was very ugly and I dislike them, because it was firstly make own circuit and I redirect them in next step.<br>
<br>Note: Code bellow is just prototype, so please excuse coding culture :-).<br><br>Thank you very much,<br>Marek<br><br>PS: Sorry for my english, Im doing my best.<br>--------<br><br>ctl.ctl.set_option(&#39;__LeaveStreamsUnattached&#39;,&#39;1&#39;)<br>
<br># Step 1 - create circuit thru specific routers<br>circ = ctl.ctl.extend_circuit(0,[&quot;ztorsrv&quot;, &#39;tornodeviennasil&#39;])<br>print &quot;circ id&quot;, circ<br><br># Step 2 - open connection to local proxy<br>
proxy = Proxy(torhost,torproxyport)<br>proxy.setEventHandler(events)<br><br># Deadlock with __LeaveStreamsUnattached=1 !!! <br># Method is probably waiting to attach stream with circuit<br>print &quot;connecting to destination&quot;<br>
proxy.connect(&#39;<a href="http://slush.cz">slush.cz</a>&#39;, 80)<br><br># Im waiting for callback from Tor controller. In stream_id will be<br># filled correct stream # assigned with my socket connection.<br># In final concept, I will use standard locks etc...<br>
while(not stream_id):<br>&nbsp;&nbsp;&nbsp; time.sleep(1)<br>&nbsp;&nbsp;&nbsp; print &quot;Stream id&quot;, stream_id<br>print &quot;Stream id&quot;, stream_id<br><br># Step 3 - connect stream and circuit<br>ctl.ctl.attach_stream(stream_id, circ)<br>
<br># Step 4 - doing communication<br>proxy.send(&quot;GET /tortest.php HTTP/1.1\r\nHost: <a href="http://slush.cz">slush.cz</a>\r\n\r\n&quot;)<br>proxy.recv()<br>proxy.close()<br>