tor_extend 1.0.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Change.log +8 -6
- data/ReadME.txt +68 -9
- data/doc/ReadME_txt.html +100 -12
- data/doc/Tor.html +5 -0
- data/doc/Tor/Bridge.html +4 -0
- data/doc/Tor/CachedDesc.html +10 -6
- data/doc/Tor/Circuit.html +791 -0
- data/doc/Tor/Constants.html +10 -0
- data/doc/Tor/LongCircuit.html +474 -0
- data/doc/Tor/Router.html +4 -0
- data/doc/Tor/StatsObj.html +4 -0
- data/doc/Tor/TController.html +85 -33
- data/doc/created.rid +7 -6
- data/doc/index.html +4 -0
- data/doc/js/search_index.js +1 -1
- data/doc/lib/circuits_rb.html +97 -0
- data/doc/lib/constants_rb.html +4 -0
- data/doc/lib/httpmod_rb.html +4 -0
- data/doc/lib/tcontroller_rb.html +4 -0
- data/doc/lib/tor_extend_rb.html +4 -0
- data/doc/lib/tstats_rb.html +4 -0
- data/doc/table_of_contents.html +50 -0
- data/lib/circuits.rb +370 -0
- data/lib/constants.rb +4 -0
- data/lib/tcontroller.rb +30 -10
- data/lib/tor_extend.rb +4 -0
- data/tor_extend.gemspec +17 -4
- metadata +42 -14
data/Change.log
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
-
Changes since version 1.0.1 -> 1.0.2
|
2
|
-
~~~~~~~~~~~~~~~~~~~~~~~
|
1
|
+
<b>Changes since version 1.0.1 -> 1.0.2 </b>.
|
3
2
|
|
4
3
|
1. Added Tor::TController.ds : returns ["w.x.y.z:port", ...]
|
5
4
|
2. Removed the Tor::Cacheddesc.ds
|
6
5
|
3. Removed the database column for dssource
|
7
6
|
4. Added a few more documentation to the source
|
8
7
|
|
9
|
-
|
10
|
-
Added circuit.rb
|
11
|
-
added class Circuit
|
12
|
-
|
8
|
+
#== version 2.0.0
|
9
|
+
#* Added circuit.rb
|
10
|
+
# * added class Circuit and all the methods.
|
11
|
+
# * added LongCircuit
|
12
|
+
# * Added events to check if each subcircuit is built (i.e applications launched and built)
|
13
|
+
#* Modified ReadME
|
14
|
+
#* Changed get_bridges so that it returns empty array when nil
|
data/ReadME.txt
CHANGED
@@ -1,19 +1,26 @@
|
|
1
|
+
<b>tor_extend.</b>
|
2
|
+
|
3
|
+
Technical details of the tor attack and slides from the conferences can be found at the CVO blog[http://cvo-lab.blogspot.com/2011/11/tor-attack-technical-details.html].
|
4
|
+
|
1
5
|
Please see the Unlicence disclaimer in Bendiken's tor-ruby gem.
|
2
6
|
|
3
7
|
<b>Installation instruction </b>
|
4
8
|
|
5
|
-
Run "gem install tor_extend"
|
9
|
+
Run "gem install tor_extend" and the dependencies will be installed along with the most recent published tor_extend library.
|
10
|
+
|
11
|
+
Version 2.0.0 requires eventmachine, which i turn requires java on a linux system. If there is any error, run "gem list eventmachine" to make sure eventmachine is installed. The library will try to install the requirements (except Java) automatically from the rubygems website.
|
12
|
+
|
13
|
+
If internet connection is available, it will install the Bendiken's tor-ruby gem as well if it is not already installed. socksify[http://socksify.rubyforge.org/] and geoip[http://geoip.rubyforge.org/] gem will also be installed.
|
6
14
|
|
7
|
-
|
8
|
-
|
9
|
-
Visit Bendiken's page[http://cypherpunk.rubyforge.org/tor/] for details on .
|
15
|
+
For offline users, obtain a local copy of the Tor gem and install before proceeding. The gem can be downloaded at Rubyforge[http://rubyforge.org/projects/tor-extend/] and Rubygem[https://rubygems.org/gems/tor_extend], or the CVO-blog[http://cvo-lab.blogspot.com/2011/11/tor-attack-technical-details.html]].
|
16
|
+
Visit Bendiken's page[http://cypherpunk.rubyforge.org/tor/] for details on his original tor library.
|
10
17
|
|
11
18
|
ri documentation included with examples.
|
12
19
|
Run "ri Tor::TController" after install to see examples.
|
13
20
|
|
14
21
|
<b>Examples</b>.
|
15
22
|
|
16
|
-
- How to use Tor
|
23
|
+
- How to use the extended Tor controller
|
17
24
|
|
18
25
|
require 'tor_extend'
|
19
26
|
proxy_config={:type=>'tor' ,:port=>9050,:addr=>'127.0.0.1'},
|
@@ -32,6 +39,7 @@ Run "ri Tor::TController" after install to see examples.
|
|
32
39
|
x.sr(:resetconf,'orport')
|
33
40
|
x.extendcir(0, [A,B,C,D,E,F,G] )
|
34
41
|
x.extendcir_slowly([A,B,C,D,E,F,G] )
|
42
|
+
|
35
43
|
x.ds => ["a.b.c.d:z", "e.f.g.h:y",...]
|
36
44
|
|
37
45
|
*Note*: The sr() function sends protocol messages and retrieves the response up to the next "250 OK" or error "5YZ".
|
@@ -171,6 +179,8 @@ Some of these fingerprints might have changed, but you can obtain fast relays fo
|
|
171
179
|
# But B can also be an guard or exit relay, no restrictions
|
172
180
|
C = mytor.get_purposeip("exit fast")
|
173
181
|
url = URI.parse "https://bridges.torproject.org/"
|
182
|
+
# This allows modification if the address is not the same in the future.
|
183
|
+
bridgelist = []
|
174
184
|
C.count.times{|z|
|
175
185
|
entryg = A[rand(A.count)]
|
176
186
|
relayg = B[rand(B.count)]
|
@@ -178,13 +188,62 @@ Some of these fingerprints might have changed, but you can obtain fast relays fo
|
|
178
188
|
circuit1 = [entryg,relayg, exitn]
|
179
189
|
cir_num = mytor.extendcir(0, circuit1)
|
180
190
|
if mytor.cir_status.detect{|p| p =~ /#{cir_num} BUILT/}
|
181
|
-
mytor.get_bridges(url,cachedf)
|
191
|
+
bridgelist |= mytor.get_bridges(url,cachedf)
|
182
192
|
else
|
183
193
|
sleep(2)
|
184
|
-
|
185
|
-
end
|
194
|
+
bridgelist |= mytor.get_bridges( url, cachedf ) #bridges are added to the database automatically
|
195
|
+
end
|
196
|
+
puts bridgelist.count
|
197
|
+
puts bridgelist
|
186
198
|
}
|
187
199
|
|
188
200
|
|
189
|
-
|
201
|
+
More results can be obtained using all exits, instead of just fast exits.
|
190
202
|
Or other distributed networks.
|
203
|
+
|
204
|
+
|
205
|
+
<b> New in Version 2.0.0 </b>.
|
206
|
+
|
207
|
+
This supports all the functionality present in version 1.0.2, and much more. Circuits are now object oriented.
|
208
|
+
Tor::Controller.authenticate is called during the initialization of Tor::Controller
|
209
|
+
|
210
|
+
tcontrol = {:host=>'127.0.0.1',:port => 9051, :password=> "control_password"}
|
211
|
+
mytor=Tor::TController.new(tctrl)
|
212
|
+
polipoport = nil
|
213
|
+
circuit_list = ["A","B","C"]
|
214
|
+
Circuit.new(tcontrol, circuit_list, proxyport)
|
215
|
+
Circuit.closecir # => This closes the circuit
|
216
|
+
Circuit.close_apps # => This will close polipo and Tor if new instances were launched for the Circuit object
|
217
|
+
Circuit.built? # => Checks if the circuit has been built
|
218
|
+
Circuit.cirnum # => Returns the circuit number of an established circuit
|
219
|
+
Circuit.launched? # => Checks if the Circuit.launch method has been called
|
220
|
+
Cirucit.launch # => This Starts Tor and Polipo if needed and extends the circuit
|
221
|
+
Circuit.extend # => Establishes circuit using the instance variables in the object
|
222
|
+
Circuit.start # => launches, extends and attaches new streams
|
223
|
+
|
224
|
+
Event machine is now used to attach all streams to a particular circuit. The Ruby eventmachine-0.1.2 requires java to be present before install. It may have other dependencies. Install event machine using "gem install eventmachine". tor-extend-2.0.0 and above will try to install it automatically during install.
|
225
|
+
|
226
|
+
If proxyport is not nil, then it is assumed that a new instance of Tor and Polipo is to be run, and it uses the preceeding proxy port as the HTTPproxy settings for running Tor . The library will start Tor using a temporary directory to save the configuration files..
|
227
|
+
|
228
|
+
<b> Example </b>.
|
229
|
+
|
230
|
+
The example below creates a 9 node circuit by using a 3 nodes circuit 3 times. It uses the preceding circuit as the proxy for the next one. An instance of Tor is already started using port 9051 as the control port,
|
231
|
+
Polipo is also assumed to be running on the port provided and assumed to be connecting through the running instance of Tor. In this case, is available on port 8118.
|
232
|
+
Suitable exit / entry nodes would have to be selected, one that does not restrict access to the entry OR port and address. Future release of the library could read the access policies and automatically check for suitable matchups.
|
233
|
+
|
234
|
+
require 'tor_extend'
|
235
|
+
tcontrolarray = [ {:host=>'127.0.0.1',:port => 9051, :password=> "controlpassword"}, {:host=>'127.0.0.1',:port => 9053},
|
236
|
+
{:host=>'127.0.0.1',:port => 9055}, {:host=>'127.0.0.1',:port => 9057} ]
|
237
|
+
proxyconfig = 8118 # I can "getconf SocksPort" from circuitarray[0] to determine the first array member here
|
238
|
+
# orarray = ["A","B","C", "E","F","G", "I","J","K", "A","B","C"] => circuit EFG is built over ABC, and IJK over EFG. ABC is then built over IJK
|
239
|
+
orarray = ["CrazyHorse","bauruine2","OxylBeta"] *3
|
240
|
+
test = Tor::LongCircuit.new(tcontrolarray, orarray,proxyconfig)
|
241
|
+
test.attach_streams #=> Starts the event reactor, and launches all the sub-circuits, and attaches streams when ever possible
|
242
|
+
#=> Events are periodic, default is 7 seconds. Change timer by setting a value in Tor::PERIODIC_TIMER
|
243
|
+
Tor::LongCircuit.built? #=> Checks if all subcircuits have been built
|
244
|
+
Tor::LongCircuit.cirnum #=> Returns the cirnum of the first subcircuit
|
245
|
+
Tor::LongCircuit.circuit #=> Returns a list of the ORs used to initialize the object
|
246
|
+
Tor::LongCircuit.close_apps #=> Closes any Tor and Polipo instance that was launched by subcircuits.
|
247
|
+
|
248
|
+
|
249
|
+
The possibility is limitless. To profile ORs, the has_many property can be used in the database to allow multiple IP addresses or fingerprints.
|
data/doc/ReadME_txt.html
CHANGED
@@ -65,8 +65,12 @@
|
|
65
65
|
|
66
66
|
<li><a href="./Tor/CachedDesc.html">Tor::CachedDesc</a>
|
67
67
|
|
68
|
+
<li><a href="./Tor/Circuit.html">Tor::Circuit</a>
|
69
|
+
|
68
70
|
<li><a href="./Tor/Constants.html">Tor::Constants</a>
|
69
71
|
|
72
|
+
<li><a href="./Tor/LongCircuit.html">Tor::LongCircuit</a>
|
73
|
+
|
70
74
|
<li><a href="./Tor/Router.html">Tor::Router</a>
|
71
75
|
|
72
76
|
<li><a href="./Tor/StatsObj.html">Tor::StatsObj</a>
|
@@ -81,25 +85,43 @@
|
|
81
85
|
|
82
86
|
<div id="documentation" class="description">
|
83
87
|
|
88
|
+
<p><strong>tor_extend.</strong></p>
|
89
|
+
|
90
|
+
<p>Technical details of the tor attack and slides from the conferences can be
|
91
|
+
found at the CVO <a
|
92
|
+
href="http://cvo-lab.blogspot.com/2011/11/tor-attack-technical-details.html">blog</a>.</p>
|
93
|
+
|
84
94
|
<p>Please see the Unlicence disclaimer in Bendiken’s tor-ruby gem.</p>
|
85
95
|
|
86
96
|
<p><strong>Installation instruction </strong></p>
|
87
97
|
|
88
|
-
<p>Run “gem install tor_extend
|
98
|
+
<p>Run “gem install tor_extend” and the dependencies will be installed along
|
99
|
+
with the most recent published tor_extend library.</p>
|
89
100
|
|
90
|
-
<p>
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
101
|
+
<p>Version 2.0.0 requires eventmachine, which i turn requires java on a linux
|
102
|
+
system. If there is any error, run “gem list eventmachine” to make sure
|
103
|
+
eventmachine is installed. The library will try to install the requirements
|
104
|
+
(except Java) automatically from the rubygems website.</p>
|
105
|
+
|
106
|
+
<p>If internet connection is available, it will install the Bendiken’s
|
107
|
+
tor-ruby gem as well if it is not already installed. <a
|
108
|
+
href="http://socksify.rubyforge.org/">socksify</a> and <a
|
109
|
+
href="http://geoip.rubyforge.org/">geoip</a> gem will also be installed.</p>
|
110
|
+
|
111
|
+
<p>For offline users, obtain a local copy of the <a href="Tor.html">Tor</a>
|
112
|
+
gem and install before proceeding. The gem can be downloaded at <a
|
113
|
+
href="http://rubyforge.org/projects/tor-extend/">Rubyforge</a> and <a
|
114
|
+
href="https://rubygems.org/gems/tor_extend">Rubygem</a>, or the <a
|
115
|
+
href="http://cvo-lab.blogspot.com/2011/11/tor-attack-technical-details.html">CVO-blog</a>].
|
116
|
+
Visit Bendiken’s <a href="http://cypherpunk.rubyforge.org/tor/">page</a>
|
117
|
+
for details on his original tor library.</p>
|
96
118
|
|
97
119
|
<p>ri documentation included with examples. Run “ri Tor::TController” after
|
98
120
|
install to see examples.</p>
|
99
121
|
|
100
122
|
<p><strong>Examples</strong>.</p>
|
101
123
|
<ul><li>
|
102
|
-
<p>How to use <a href="Tor.html">Tor</a>
|
124
|
+
<p>How to use the extended <a href="Tor.html">Tor</a> controller</p>
|
103
125
|
|
104
126
|
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'tor_extend'</span>
|
105
127
|
<span class="ruby-identifier">proxy_config</span>={:<span class="ruby-identifier">type=</span><span class="ruby-operator">></span><span class="ruby-string">'tor'</span> ,:<span class="ruby-identifier">port=</span><span class="ruby-operator">></span><span class="ruby-value">9050</span>,:<span class="ruby-identifier">addr=</span><span class="ruby-operator">></span><span class="ruby-string">'127.0.0.1'</span>},
|
@@ -271,6 +293,8 @@ relays for the test below</p>
|
|
271
293
|
<span class="ruby-comment"># But B can also be an guard or exit relay, no restrictions</span>
|
272
294
|
<span class="ruby-constant">C</span> = <span class="ruby-identifier">mytor</span>.<span class="ruby-identifier">get_purposeip</span>(<span class="ruby-string">"exit fast"</span>)
|
273
295
|
<span class="ruby-identifier">url</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span> <span class="ruby-string">"https://bridges.torproject.org/"</span>
|
296
|
+
<span class="ruby-comment"># This allows modification if the address is not the same in the future.</span>
|
297
|
+
<span class="ruby-identifier">bridgelist</span> = []
|
274
298
|
<span class="ruby-constant">C</span>.<span class="ruby-identifier">count</span>.<span class="ruby-identifier">times</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">z</span><span class="ruby-operator">|</span>
|
275
299
|
<span class="ruby-identifier">entryg</span> = <span class="ruby-constant">A</span>[<span class="ruby-identifier">rand</span>(<span class="ruby-constant">A</span>.<span class="ruby-identifier">count</span>)]
|
276
300
|
<span class="ruby-identifier">relayg</span> = <span class="ruby-constant">B</span>[<span class="ruby-identifier">rand</span>(<span class="ruby-constant">B</span>.<span class="ruby-identifier">count</span>)]
|
@@ -278,17 +302,81 @@ relays for the test below</p>
|
|
278
302
|
<span class="ruby-identifier">circuit1</span> = [<span class="ruby-identifier">entryg</span>,<span class="ruby-identifier">relayg</span>, <span class="ruby-identifier">exitn</span>]
|
279
303
|
<span class="ruby-identifier">cir_num</span> = <span class="ruby-identifier">mytor</span>.<span class="ruby-identifier">extendcir</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">circuit1</span>)
|
280
304
|
<span class="ruby-keyword">if</span> <span class="ruby-identifier">mytor</span>.<span class="ruby-identifier">cir_status</span>.<span class="ruby-identifier">detect</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span> <span class="ruby-identifier">p</span> <span class="ruby-operator">=~</span> <span class="ruby-node">/#{cir_num} BUILT/</span>}
|
281
|
-
<span class="ruby-identifier">mytor</span>.<span class="ruby-identifier">get_bridges</span>(<span class="ruby-identifier">url</span>,<span class="ruby-identifier">cachedf</span>)
|
305
|
+
<span class="ruby-identifier">bridgelist</span> <span class="ruby-operator">|=</span> <span class="ruby-identifier">mytor</span>.<span class="ruby-identifier">get_bridges</span>(<span class="ruby-identifier">url</span>,<span class="ruby-identifier">cachedf</span>)
|
282
306
|
<span class="ruby-keyword">else</span>
|
283
307
|
<span class="ruby-identifier">sleep</span>(<span class="ruby-value">2</span>)
|
284
|
-
<span class="ruby-identifier">
|
285
|
-
<span class="ruby-keyword">end</span>
|
308
|
+
<span class="ruby-identifier">bridgelist</span> <span class="ruby-operator">|=</span> <span class="ruby-identifier">mytor</span>.<span class="ruby-identifier">get_bridges</span>( <span class="ruby-identifier">url</span>, <span class="ruby-identifier">cachedf</span> ) <span class="ruby-comment">#bridges are added to the database automatically</span>
|
309
|
+
<span class="ruby-keyword">end</span>
|
310
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">bridgelist</span>.<span class="ruby-identifier">count</span>
|
311
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">bridgelist</span>
|
286
312
|
}
|
287
313
|
</pre>
|
288
314
|
|
289
|
-
<p>
|
315
|
+
<p>More results can be obtained using all exits, instead of just fast exits.
|
290
316
|
Or other distributed networks.</p>
|
291
317
|
|
318
|
+
<p><strong> New in Version 2.0.0 </strong>.</p>
|
319
|
+
|
320
|
+
<p>This supports all the functionality present in version 1.0.2, and much
|
321
|
+
more. Circuits are now object oriented. Tor::Controller.authenticate is
|
322
|
+
called during the initialization of Tor::Controller</p>
|
323
|
+
|
324
|
+
<pre class="ruby"><span class="ruby-identifier">tcontrol</span> = {:<span class="ruby-identifier">host=</span><span class="ruby-operator">></span><span class="ruby-string">'127.0.0.1'</span>,:<span class="ruby-identifier">port</span> =<span class="ruby-operator">></span> <span class="ruby-value">9051</span>, :<span class="ruby-identifier">password=</span><span class="ruby-operator">></span> <span class="ruby-string">"control_password"</span>}
|
325
|
+
<span class="ruby-identifier">mytor</span>=<span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">TController</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">tctrl</span>)
|
326
|
+
<span class="ruby-identifier">polipoport</span> = <span class="ruby-keyword">nil</span>
|
327
|
+
<span class="ruby-identifier">circuit_list</span> = [<span class="ruby-string">"A"</span>,<span class="ruby-string">"B"</span>,<span class="ruby-string">"C"</span>]
|
328
|
+
<span class="ruby-constant">Circuit</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">tcontrol</span>, <span class="ruby-identifier">circuit_list</span>, <span class="ruby-identifier">proxyport</span>)
|
329
|
+
<span class="ruby-constant">Circuit</span>.<span class="ruby-identifier">closecir</span> <span class="ruby-comment"># => This closes the circuit</span>
|
330
|
+
<span class="ruby-constant">Circuit</span>.<span class="ruby-identifier">close_apps</span> <span class="ruby-comment"># => This will close polipo and Tor if new instances were launched for the Circuit object</span>
|
331
|
+
<span class="ruby-constant">Circuit</span>.<span class="ruby-identifier">built?</span> <span class="ruby-comment"># => Checks if the circuit has been built</span>
|
332
|
+
<span class="ruby-constant">Circuit</span>.<span class="ruby-identifier">cirnum</span> <span class="ruby-comment"># => Returns the circuit number of an established circuit</span>
|
333
|
+
<span class="ruby-constant">Circuit</span>.<span class="ruby-identifier">launched?</span> <span class="ruby-comment"># => Checks if the Circuit.launch method has been called</span>
|
334
|
+
<span class="ruby-constant">Cirucit</span>.<span class="ruby-identifier">launch</span> <span class="ruby-comment"># => This Starts Tor and Polipo if needed and extends the circuit</span>
|
335
|
+
<span class="ruby-constant">Circuit</span>.<span class="ruby-identifier">extend</span> <span class="ruby-comment"># => Establishes circuit using the instance variables in the object</span>
|
336
|
+
<span class="ruby-constant">Circuit</span>.<span class="ruby-identifier">start</span> <span class="ruby-comment"># => launches, extends and attaches new streams</span>
|
337
|
+
</pre>
|
338
|
+
|
339
|
+
<p>Event machine is now used to attach all streams to a particular circuit.
|
340
|
+
The Ruby eventmachine-0.1.2 requires java to be present before install. It
|
341
|
+
may have other dependencies. Install event machine using “gem install
|
342
|
+
eventmachine”. tor-extend-2.0.0 and above will try to install it
|
343
|
+
automatically during install.</p>
|
344
|
+
|
345
|
+
<p>If proxyport is not nil, then it is assumed that a new instance of <a
|
346
|
+
href="Tor.html">Tor</a> and Polipo is to be run, and it uses the preceeding
|
347
|
+
proxy port as the HTTPproxy settings for running <a href="Tor.html">Tor</a>
|
348
|
+
. The library will start <a href="Tor.html">Tor</a> using a temporary
|
349
|
+
directory to save the configuration files..</p>
|
350
|
+
|
351
|
+
<p><strong> Example </strong>.</p>
|
352
|
+
|
353
|
+
<p>The example below creates a 9 node circuit by using a 3 nodes circuit 3
|
354
|
+
times. It uses the preceding circuit as the proxy for the next one. An
|
355
|
+
instance of <a href="Tor.html">Tor</a> is already started using port 9051
|
356
|
+
as the control port, Polipo is also assumed to be running on the port
|
357
|
+
provided and assumed to be connecting through the running instance of <a
|
358
|
+
href="Tor.html">Tor</a>. In this case, is available on port 8118. Suitable
|
359
|
+
exit / entry nodes would have to be selected, one that does not restrict
|
360
|
+
access to the entry OR port and address. Future release of the library
|
361
|
+
could read the access policies and automatically check for suitable
|
362
|
+
matchups.</p>
|
363
|
+
|
364
|
+
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'tor_extend'</span>
|
365
|
+
<span class="ruby-identifier">tcontrolarray</span> = [ {:<span class="ruby-identifier">host=</span><span class="ruby-operator">></span><span class="ruby-string">'127.0.0.1'</span>,:<span class="ruby-identifier">port</span> =<span class="ruby-operator">></span> <span class="ruby-value">9051</span>, :<span class="ruby-identifier">password=</span><span class="ruby-operator">></span> <span class="ruby-string">"controlpassword"</span>}, {:<span class="ruby-identifier">host=</span><span class="ruby-operator">></span><span class="ruby-string">'127.0.0.1'</span>,:<span class="ruby-identifier">port</span> =<span class="ruby-operator">></span> <span class="ruby-value">9053</span>},
|
366
|
+
{:<span class="ruby-identifier">host=</span><span class="ruby-operator">></span><span class="ruby-string">'127.0.0.1'</span>,:<span class="ruby-identifier">port</span> =<span class="ruby-operator">></span> <span class="ruby-value">9055</span>}, {:<span class="ruby-identifier">host=</span><span class="ruby-operator">></span><span class="ruby-string">'127.0.0.1'</span>,:<span class="ruby-identifier">port</span> =<span class="ruby-operator">></span> <span class="ruby-value">9057</span>} ]
|
367
|
+
<span class="ruby-identifier">proxyconfig</span> = <span class="ruby-value">8118</span> <span class="ruby-comment"># I can "getconf SocksPort" from circuitarray[0] to determine the first array member here </span>
|
368
|
+
<span class="ruby-comment"># orarray = ["A","B","C", "E","F","G", "I","J","K", "A","B","C"] => circuit EFG is built over ABC, and IJK over EFG. ABC is then built over IJK</span>
|
369
|
+
<span class="ruby-identifier">orarray</span> = [<span class="ruby-string">"CrazyHorse"</span>,<span class="ruby-string">"bauruine2"</span>,<span class="ruby-string">"OxylBeta"</span>] *<span class="ruby-value">3</span>
|
370
|
+
<span class="ruby-identifier">test</span> = <span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">LongCircuit</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">tcontrolarray</span>, <span class="ruby-identifier">orarray</span>,<span class="ruby-identifier">proxyconfig</span>)
|
371
|
+
<span class="ruby-identifier">test</span>.<span class="ruby-identifier">attach_streams</span> <span class="ruby-comment">#=> Starts the event reactor, and launches all the sub-circuits, and attaches streams when ever possible </span>
|
372
|
+
<span class="ruby-comment">#=> Events are periodic, default is 7 seconds. Change timer by setting a value in Tor::PERIODIC_TIMER </span>
|
373
|
+
<span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">LongCircuit</span>.<span class="ruby-identifier">built?</span> <span class="ruby-comment">#=> Checks if all subcircuits have been built</span>
|
374
|
+
<span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">LongCircuit</span>.<span class="ruby-identifier">cirnum</span> <span class="ruby-comment">#=> Returns the cirnum of the first subcircuit</span>
|
375
|
+
<span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">LongCircuit</span>.<span class="ruby-identifier">circuit</span> <span class="ruby-comment">#=> Returns a list of the ORs used to initialize the object</span>
|
376
|
+
<span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">LongCircuit</span>.<span class="ruby-identifier">close_apps</span> <span class="ruby-comment">#=> Closes any Tor and Polipo instance that was launched by subcircuits.</span>
|
377
|
+
<span class="ruby-constant">The</span> <span class="ruby-identifier">possibility</span> <span class="ruby-identifier">is</span> <span class="ruby-identifier">limitless</span>. <span class="ruby-constant">To</span> <span class="ruby-identifier">profile</span> <span class="ruby-constant">ORs</span>, <span class="ruby-identifier">the</span> <span class="ruby-identifier">has_many</span> <span class="ruby-identifier">property</span> <span class="ruby-identifier">can</span> <span class="ruby-identifier">be</span> <span class="ruby-identifier">used</span> <span class="ruby-keyword">in</span> <span class="ruby-identifier">the</span> <span class="ruby-identifier">database</span> <span class="ruby-identifier">to</span> <span class="ruby-identifier">allow</span> <span class="ruby-identifier">multiple</span> <span class="ruby-constant">IP</span> <span class="ruby-identifier">addresses</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">fingerprints</span>.
|
378
|
+
</pre>
|
379
|
+
|
292
380
|
</div>
|
293
381
|
|
294
382
|
|
data/doc/Tor.html
CHANGED
@@ -49,6 +49,7 @@
|
|
49
49
|
<ul>
|
50
50
|
<li>lib/tor_extend.rb
|
51
51
|
<li>lib/tstats.rb
|
52
|
+
<li>lib/circuits.rb
|
52
53
|
<li>lib/tcontroller.rb
|
53
54
|
</ul>
|
54
55
|
</nav>
|
@@ -85,8 +86,12 @@
|
|
85
86
|
|
86
87
|
<li><a href="./Tor/CachedDesc.html">Tor::CachedDesc</a>
|
87
88
|
|
89
|
+
<li><a href="./Tor/Circuit.html">Tor::Circuit</a>
|
90
|
+
|
88
91
|
<li><a href="./Tor/Constants.html">Tor::Constants</a>
|
89
92
|
|
93
|
+
<li><a href="./Tor/LongCircuit.html">Tor::LongCircuit</a>
|
94
|
+
|
90
95
|
<li><a href="./Tor/Router.html">Tor::Router</a>
|
91
96
|
|
92
97
|
<li><a href="./Tor/StatsObj.html">Tor::StatsObj</a>
|
data/doc/Tor/Bridge.html
CHANGED
@@ -89,8 +89,12 @@
|
|
89
89
|
|
90
90
|
<li><a href="../Tor/CachedDesc.html">Tor::CachedDesc</a>
|
91
91
|
|
92
|
+
<li><a href="../Tor/Circuit.html">Tor::Circuit</a>
|
93
|
+
|
92
94
|
<li><a href="../Tor/Constants.html">Tor::Constants</a>
|
93
95
|
|
96
|
+
<li><a href="../Tor/LongCircuit.html">Tor::LongCircuit</a>
|
97
|
+
|
94
98
|
<li><a href="../Tor/Router.html">Tor::Router</a>
|
95
99
|
|
96
100
|
<li><a href="../Tor/StatsObj.html">Tor::StatsObj</a>
|
data/doc/Tor/CachedDesc.html
CHANGED
@@ -109,8 +109,12 @@
|
|
109
109
|
|
110
110
|
<li><a href="../Tor/CachedDesc.html">Tor::CachedDesc</a>
|
111
111
|
|
112
|
+
<li><a href="../Tor/Circuit.html">Tor::Circuit</a>
|
113
|
+
|
112
114
|
<li><a href="../Tor/Constants.html">Tor::Constants</a>
|
113
115
|
|
116
|
+
<li><a href="../Tor/LongCircuit.html">Tor::LongCircuit</a>
|
117
|
+
|
114
118
|
<li><a href="../Tor/Router.html">Tor::Router</a>
|
115
119
|
|
116
120
|
<li><a href="../Tor/StatsObj.html">Tor::StatsObj</a>
|
@@ -179,7 +183,7 @@ from <a href="Router.html">Tor::Router</a></p>
|
|
179
183
|
|
180
184
|
|
181
185
|
<div class="method-source-code" id="new-source">
|
182
|
-
<pre><span class="ruby-comment"># File lib/tor_extend.rb, line
|
186
|
+
<pre><span class="ruby-comment"># File lib/tor_extend.rb, line 57</span>
|
183
187
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">geoip_path</span>)
|
184
188
|
<span class="ruby-ivar">@stat</span> = <span class="ruby-constant">StatsObj</span>.<span class="ruby-identifier">new</span>
|
185
189
|
<span class="ruby-comment"># Tor::CachedDesc#geoipdb is an instance of GeoIP with the active database</span>
|
@@ -228,7 +232,7 @@ database if it does not already exist.</p>
|
|
228
232
|
|
229
233
|
|
230
234
|
<div class="method-source-code" id="dbconnect-source">
|
231
|
-
<pre><span class="ruby-comment"># File lib/tor_extend.rb, line
|
235
|
+
<pre><span class="ruby-comment"># File lib/tor_extend.rb, line 79</span>
|
232
236
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">dbconnect</span>(*<span class="ruby-identifier">dbconfig</span>)
|
233
237
|
<span class="ruby-identifier">dbconfig</span> = [{<span class="ruby-value">:adapter</span> =<span class="ruby-operator">></span> <span class="ruby-string">"sqlite3"</span>,<span class="ruby-value">:database</span> =<span class="ruby-operator">></span> <span class="ruby-string">"db.sqlite3"</span>}] <span class="ruby-keyword">if</span> <span class="ruby-identifier">dbconfig</span>.<span class="ruby-identifier">empty?</span>
|
234
238
|
<span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">establish_connection</span>(<span class="ruby-identifier">dbconfig</span>[<span class="ruby-value">0</span>])
|
@@ -284,7 +288,7 @@ href="CachedDesc.html">Tor::CachedDesc</a>.</p>
|
|
284
288
|
|
285
289
|
|
286
290
|
<div class="method-source-code" id="get_geoiprecord-source">
|
287
|
-
<pre><span class="ruby-comment"># File lib/tor_extend.rb, line
|
291
|
+
<pre><span class="ruby-comment"># File lib/tor_extend.rb, line 120</span>
|
288
292
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">get_geoiprecord</span>(<span class="ruby-identifier">ipaddr</span>)
|
289
293
|
<span class="ruby-identifier">or_geoip</span>=<span class="ruby-ivar">@geoipdb</span>.<span class="ruby-identifier">city</span>(<span class="ruby-identifier">ipaddr</span>)
|
290
294
|
<span class="ruby-identifier">or_geoip</span>=<span class="ruby-ivar">@geoipdb2</span>.<span class="ruby-identifier">city</span>(<span class="ruby-identifier">ipaddr</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">or_geoip</span><span class="ruby-operator">==</span><span class="ruby-keyword">nil</span>
|
@@ -320,7 +324,7 @@ what you’re doing.</p>
|
|
320
324
|
|
321
325
|
|
322
326
|
<div class="method-source-code" id="ors-source">
|
323
|
-
<pre><span class="ruby-comment"># File lib/tor_extend.rb, line
|
327
|
+
<pre><span class="ruby-comment"># File lib/tor_extend.rb, line 113</span>
|
324
328
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">ors</span>
|
325
329
|
<span class="ruby-constant">Router</span>
|
326
330
|
<span class="ruby-keyword">end</span></pre>
|
@@ -351,7 +355,7 @@ href="Router.html">Tor::Router</a> database.</p>
|
|
351
355
|
|
352
356
|
|
353
357
|
<div class="method-source-code" id="readall-source">
|
354
|
-
<pre><span class="ruby-comment"># File lib/tor_extend.rb, line
|
358
|
+
<pre><span class="ruby-comment"># File lib/tor_extend.rb, line 129</span>
|
355
359
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">readall</span>(<span class="ruby-identifier">filename</span>)
|
356
360
|
<span class="ruby-identifier">cacheddesc</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">filename</span>,<span class="ruby-string">'r:ISO-8859-1'</span>)
|
357
361
|
<span class="ruby-identifier">loopbreaker</span>=<span class="ruby-keyword">false</span>
|
@@ -443,7 +447,7 @@ href="StatsObj.html">Tor::StatsObj</a></p>
|
|
443
447
|
|
444
448
|
|
445
449
|
<div class="method-source-code" id="stat-source">
|
446
|
-
<pre><span class="ruby-comment"># File lib/tor_extend.rb, line
|
450
|
+
<pre><span class="ruby-comment"># File lib/tor_extend.rb, line 68</span>
|
447
451
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">stat</span>
|
448
452
|
<span class="ruby-ivar">@stat</span>
|
449
453
|
<span class="ruby-keyword">end</span></pre>
|
@@ -0,0 +1,791 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
6
|
+
|
7
|
+
<title>Class: Tor::Circuit</title>
|
8
|
+
|
9
|
+
<link type="text/css" media="screen" href="../rdoc.css" rel="stylesheet">
|
10
|
+
|
11
|
+
<script type="text/javascript">
|
12
|
+
var rdoc_rel_prefix = "../";
|
13
|
+
</script>
|
14
|
+
|
15
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
16
|
+
<script type="text/javascript" charset="utf-8" src="../js/navigation.js"></script>
|
17
|
+
<script type="text/javascript" charset="utf-8" src="../js/search_index.js"></script>
|
18
|
+
<script type="text/javascript" charset="utf-8" src="../js/search.js"></script>
|
19
|
+
<script type="text/javascript" charset="utf-8" src="../js/searcher.js"></script>
|
20
|
+
<script type="text/javascript" charset="utf-8" src="../js/darkfish.js"></script>
|
21
|
+
|
22
|
+
|
23
|
+
<body id="top" class="class">
|
24
|
+
<nav id="metadata">
|
25
|
+
<nav id="home-section" class="section">
|
26
|
+
<h3 class="section-header">
|
27
|
+
<a href="../index.html">Home</a>
|
28
|
+
<a href="../table_of_contents.html#classes">Classes</a>
|
29
|
+
<a href="../table_of_contents.html#methods">Methods</a>
|
30
|
+
</h3>
|
31
|
+
</nav>
|
32
|
+
|
33
|
+
|
34
|
+
<nav id="search-section" class="section project-section" class="initially-hidden">
|
35
|
+
<form action="#" method="get" accept-charset="utf-8">
|
36
|
+
<h3 class="section-header">
|
37
|
+
<input type="text" name="search" placeholder="Search" id="search-field"
|
38
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
39
|
+
</h3>
|
40
|
+
</form>
|
41
|
+
|
42
|
+
<ul id="search-results" class="initially-hidden"></ul>
|
43
|
+
</nav>
|
44
|
+
|
45
|
+
|
46
|
+
<div id="file-metadata">
|
47
|
+
<nav id="file-list-section" class="section">
|
48
|
+
<h3 class="section-header">Defined In</h3>
|
49
|
+
<ul>
|
50
|
+
<li>lib/circuits.rb
|
51
|
+
</ul>
|
52
|
+
</nav>
|
53
|
+
|
54
|
+
|
55
|
+
</div>
|
56
|
+
|
57
|
+
<div id="class-metadata">
|
58
|
+
|
59
|
+
<nav id="parent-class-section" class="section">
|
60
|
+
<h3 class="section-header">Parent</h3>
|
61
|
+
|
62
|
+
<p class="link">Object
|
63
|
+
|
64
|
+
</nav>
|
65
|
+
|
66
|
+
|
67
|
+
<!-- Method Quickref -->
|
68
|
+
<nav id="method-list-section" class="section">
|
69
|
+
<h3 class="section-header">Methods</h3>
|
70
|
+
|
71
|
+
<ul class="link-list">
|
72
|
+
|
73
|
+
<li><a href="#method-c-new">::new</a>
|
74
|
+
|
75
|
+
<li><a href="#method-i-attach_streams">#attach_streams</a>
|
76
|
+
|
77
|
+
<li><a href="#method-i-built-3F">#built?</a>
|
78
|
+
|
79
|
+
<li><a href="#method-i-circuit">#circuit</a>
|
80
|
+
|
81
|
+
<li><a href="#method-i-cirnum">#cirnum</a>
|
82
|
+
|
83
|
+
<li><a href="#method-i-close_apps">#close_apps</a>
|
84
|
+
|
85
|
+
<li><a href="#method-i-closecir">#closecir</a>
|
86
|
+
|
87
|
+
<li><a href="#method-i-closed-3F">#closed?</a>
|
88
|
+
|
89
|
+
<li><a href="#method-i-controller">#controller</a>
|
90
|
+
|
91
|
+
<li><a href="#method-i-extend">#extend</a>
|
92
|
+
|
93
|
+
<li><a href="#method-i-get_bridges">#get_bridges</a>
|
94
|
+
|
95
|
+
<li><a href="#method-i-launch">#launch</a>
|
96
|
+
|
97
|
+
<li><a href="#method-i-launched-3F">#launched?</a>
|
98
|
+
|
99
|
+
<li><a href="#method-i-start">#start</a>
|
100
|
+
|
101
|
+
</ul>
|
102
|
+
</nav>
|
103
|
+
|
104
|
+
</div>
|
105
|
+
|
106
|
+
<div id="project-metadata">
|
107
|
+
<nav id="fileindex-section" class="section project-section">
|
108
|
+
<h3 class="section-header">Pages</h3>
|
109
|
+
|
110
|
+
<ul>
|
111
|
+
|
112
|
+
<li class="file"><a href="../ReadME_txt.html">ReadME</a>
|
113
|
+
|
114
|
+
</ul>
|
115
|
+
</nav>
|
116
|
+
|
117
|
+
<nav id="classindex-section" class="section project-section">
|
118
|
+
<h3 class="section-header">Class and Module Index</h3>
|
119
|
+
|
120
|
+
<ul class="link-list">
|
121
|
+
|
122
|
+
<li><a href="../Tor.html">Tor</a>
|
123
|
+
|
124
|
+
<li><a href="../Tor/Bridge.html">Tor::Bridge</a>
|
125
|
+
|
126
|
+
<li><a href="../Tor/CachedDesc.html">Tor::CachedDesc</a>
|
127
|
+
|
128
|
+
<li><a href="../Tor/Circuit.html">Tor::Circuit</a>
|
129
|
+
|
130
|
+
<li><a href="../Tor/Constants.html">Tor::Constants</a>
|
131
|
+
|
132
|
+
<li><a href="../Tor/LongCircuit.html">Tor::LongCircuit</a>
|
133
|
+
|
134
|
+
<li><a href="../Tor/Router.html">Tor::Router</a>
|
135
|
+
|
136
|
+
<li><a href="../Tor/StatsObj.html">Tor::StatsObj</a>
|
137
|
+
|
138
|
+
<li><a href="../Tor/TController.html">Tor::TController</a>
|
139
|
+
|
140
|
+
</ul>
|
141
|
+
</nav>
|
142
|
+
|
143
|
+
</div>
|
144
|
+
</nav>
|
145
|
+
|
146
|
+
<div id="documentation">
|
147
|
+
<h1 class="class">class Tor::Circuit</h1>
|
148
|
+
|
149
|
+
<div id="description" class="description">
|
150
|
+
|
151
|
+
<p>This is a single (sub-)circuit object over exactly 3 nodes.Suitable nodes
|
152
|
+
must be chosesn to allow the creation of a successful circuit.</p>
|
153
|
+
|
154
|
+
</div><!-- description -->
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
<!-- Methods -->
|
169
|
+
|
170
|
+
<section id="public-class-5Buntitled-5D-method-details" class="method-section section">
|
171
|
+
<h3 class="section-header">Public Class Methods</h3>
|
172
|
+
|
173
|
+
|
174
|
+
<div id="method-c-new" class="method-detail ">
|
175
|
+
|
176
|
+
<div class="method-heading">
|
177
|
+
<span class="method-name">new</span><span
|
178
|
+
class="method-args">(ctrller_config, circuitarray, proxyconfig)</span>
|
179
|
+
<span class="method-click-advice">click to toggle source</span>
|
180
|
+
</div>
|
181
|
+
|
182
|
+
|
183
|
+
<div class="method-description">
|
184
|
+
|
185
|
+
<p>Initialises a <a href="Circuit.html">Tor::Circuit</a> instance variable
|
186
|
+
with attibutes including the @built, @cirnum and @torcontroller Use nil for
|
187
|
+
proxyport if <a href="../Tor.html">Tor</a> is running already.</p>
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
<div class="method-source-code" id="new-source">
|
192
|
+
<pre><span class="ruby-comment"># File lib/circuits.rb, line 8</span>
|
193
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">ctrller_config</span>, <span class="ruby-identifier">circuitarray</span>, <span class="ruby-identifier">proxyconfig</span>)
|
194
|
+
<span class="ruby-ivar">@built</span> = <span class="ruby-keyword">true</span>
|
195
|
+
<span class="ruby-ivar">@closed</span> = <span class="ruby-keyword">true</span>
|
196
|
+
<span class="ruby-ivar">@circuitarray</span> = <span class="ruby-identifier">circuitarray</span>
|
197
|
+
<span class="ruby-ivar">@cirnum</span> = <span class="ruby-keyword">nil</span>
|
198
|
+
<span class="ruby-ivar">@ctrller_config</span> = <span class="ruby-identifier">ctrller_config</span>
|
199
|
+
<span class="ruby-ivar">@proxyconfig</span> = <span class="ruby-identifier">proxyconfig</span>
|
200
|
+
<span class="ruby-keyword">if</span> <span class="ruby-ivar">@proxyconfig</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-comment"># When proxyconfig.nil?, then it's an existing </span>
|
201
|
+
<span class="ruby-ivar">@launched</span> = <span class="ruby-keyword">true</span>
|
202
|
+
<span class="ruby-ivar">@torcontroller</span> = <span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">TController</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@ctrller_config</span>)
|
203
|
+
<span class="ruby-keyword">else</span>
|
204
|
+
<span class="ruby-ivar">@launched</span> = <span class="ruby-keyword">false</span>
|
205
|
+
<span class="ruby-keyword">end</span>
|
206
|
+
<span class="ruby-keyword">end</span></pre>
|
207
|
+
</div><!-- new-source -->
|
208
|
+
|
209
|
+
</div>
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
</div><!-- new-method -->
|
215
|
+
|
216
|
+
|
217
|
+
</section><!-- public-class-method-details -->
|
218
|
+
|
219
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section section">
|
220
|
+
<h3 class="section-header">Public Instance Methods</h3>
|
221
|
+
|
222
|
+
|
223
|
+
<div id="method-i-attach_streams" class="method-detail ">
|
224
|
+
|
225
|
+
<div class="method-heading">
|
226
|
+
<span class="method-name">attach_streams</span><span
|
227
|
+
class="method-args">()</span>
|
228
|
+
<span class="method-click-advice">click to toggle source</span>
|
229
|
+
</div>
|
230
|
+
|
231
|
+
|
232
|
+
<div class="method-description">
|
233
|
+
|
234
|
+
<p>This tries to attach all streams to the circuit.</p>
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
<div class="method-source-code" id="attach_streams-source">
|
239
|
+
<pre><span class="ruby-comment"># File lib/circuits.rb, line 164</span>
|
240
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">attach_streams</span>
|
241
|
+
<span class="ruby-identifier">controller</span>.<span class="ruby-identifier">newstreams</span>.<span class="ruby-identifier">each</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">z</span><span class="ruby-operator">|</span>
|
242
|
+
<span class="ruby-identifier">controller</span>.<span class="ruby-identifier">attach_stream</span>(<span class="ruby-identifier">z</span>,<span class="ruby-ivar">@cirnum</span>)
|
243
|
+
}
|
244
|
+
<span class="ruby-keyword">end</span></pre>
|
245
|
+
</div><!-- attach_streams-source -->
|
246
|
+
|
247
|
+
</div>
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
|
252
|
+
</div><!-- attach_streams-method -->
|
253
|
+
|
254
|
+
|
255
|
+
<div id="method-i-built-3F" class="method-detail ">
|
256
|
+
|
257
|
+
<div class="method-heading">
|
258
|
+
<span class="method-name">built?</span><span
|
259
|
+
class="method-args">()</span>
|
260
|
+
<span class="method-click-advice">click to toggle source</span>
|
261
|
+
</div>
|
262
|
+
|
263
|
+
|
264
|
+
<div class="method-description">
|
265
|
+
|
266
|
+
<p>This methods checks if the circuit has been built. It only reflects a
|
267
|
+
single segment of the circuit</p>
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
<div class="method-source-code" id="built-3F-source">
|
272
|
+
<pre><span class="ruby-comment"># File lib/circuits.rb, line 76</span>
|
273
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">built?</span>
|
274
|
+
<span class="ruby-keyword">if</span> <span class="ruby-keyword">defined?</span>(<span class="ruby-ivar">@torcontroller</span>) <span class="ruby-comment"># cant check built? before launching.</span>
|
275
|
+
<span class="ruby-ivar">@built</span> = <span class="ruby-operator">!</span> <span class="ruby-ivar">@torcontroller</span>.<span class="ruby-identifier">cir_status</span>.<span class="ruby-identifier">detect</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">z</span><span class="ruby-operator">|</span> <span class="ruby-identifier">z</span> <span class="ruby-operator">=~</span> <span class="ruby-node">/#{@cirnum} BUILT/</span> }.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword">if</span> <span class="ruby-keyword">not</span> <span class="ruby-ivar">@cirnum</span>.<span class="ruby-identifier">nil?</span>
|
276
|
+
<span class="ruby-keyword">else</span>
|
277
|
+
<span class="ruby-keyword">false</span>
|
278
|
+
<span class="ruby-keyword">end</span>
|
279
|
+
<span class="ruby-keyword">end</span></pre>
|
280
|
+
</div><!-- built-3F-source -->
|
281
|
+
|
282
|
+
</div>
|
283
|
+
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
</div><!-- built-3F-method -->
|
288
|
+
|
289
|
+
|
290
|
+
<div id="method-i-circuit" class="method-detail ">
|
291
|
+
|
292
|
+
<div class="method-heading">
|
293
|
+
<span class="method-name">circuit</span><span
|
294
|
+
class="method-args">()</span>
|
295
|
+
<span class="method-click-advice">click to toggle source</span>
|
296
|
+
</div>
|
297
|
+
|
298
|
+
|
299
|
+
<div class="method-description">
|
300
|
+
|
301
|
+
<p>Returns the nodes that make up the circuit.</p>
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
<div class="method-source-code" id="circuit-source">
|
306
|
+
<pre><span class="ruby-comment"># File lib/circuits.rb, line 24</span>
|
307
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">circuit</span>
|
308
|
+
<span class="ruby-ivar">@circuitarray</span>
|
309
|
+
<span class="ruby-keyword">end</span></pre>
|
310
|
+
</div><!-- circuit-source -->
|
311
|
+
|
312
|
+
</div>
|
313
|
+
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
</div><!-- circuit-method -->
|
318
|
+
|
319
|
+
|
320
|
+
<div id="method-i-cirnum" class="method-detail ">
|
321
|
+
|
322
|
+
<div class="method-heading">
|
323
|
+
<span class="method-name">cirnum</span><span
|
324
|
+
class="method-args">()</span>
|
325
|
+
<span class="method-click-advice">click to toggle source</span>
|
326
|
+
</div>
|
327
|
+
|
328
|
+
|
329
|
+
<div class="method-description">
|
330
|
+
|
331
|
+
<p>Returns the circuit number. Returns 0 if it has not been attached</p>
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
<div class="method-source-code" id="cirnum-source">
|
336
|
+
<pre><span class="ruby-comment"># File lib/circuits.rb, line 36</span>
|
337
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">cirnum</span>
|
338
|
+
<span class="ruby-ivar">@cirnum</span>
|
339
|
+
<span class="ruby-keyword">end</span></pre>
|
340
|
+
</div><!-- cirnum-source -->
|
341
|
+
|
342
|
+
</div>
|
343
|
+
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
</div><!-- cirnum-method -->
|
348
|
+
|
349
|
+
|
350
|
+
<div id="method-i-close_apps" class="method-detail ">
|
351
|
+
|
352
|
+
<div class="method-heading">
|
353
|
+
<span class="method-name">close_apps</span><span
|
354
|
+
class="method-args">()</span>
|
355
|
+
<span class="method-click-advice">click to toggle source</span>
|
356
|
+
</div>
|
357
|
+
|
358
|
+
|
359
|
+
<div class="method-description">
|
360
|
+
|
361
|
+
<p>Closes the <a href="../Tor.html">Tor</a> and Polipo launched by the
|
362
|
+
instance of this class, and removes the tmp directory</p>
|
363
|
+
|
364
|
+
|
365
|
+
|
366
|
+
<div class="method-source-code" id="close_apps-source">
|
367
|
+
<pre><span class="ruby-comment"># File lib/circuits.rb, line 152</span>
|
368
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">close_apps</span>
|
369
|
+
<span class="ruby-keyword">if</span> <span class="ruby-keyword">defined?</span>(<span class="ruby-ivar">@pid</span>)
|
370
|
+
<span class="ruby-ivar">@torcontroller</span>.<span class="ruby-identifier">signal</span>(<span class="ruby-string">"SHUTDOWN"</span>)
|
371
|
+
<span class="ruby-constant">Process</span>.<span class="ruby-identifier">kill</span>(<span class="ruby-string">"KILL"</span>,<span class="ruby-ivar">@pid</span>[<span class="ruby-value">:polipo</span>])
|
372
|
+
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">remove_entry_secure</span> <span class="ruby-ivar">@path</span> <span class="ruby-comment"># srm path ( delete tmp directory recursively )</span>
|
373
|
+
<span class="ruby-ivar">@launched</span>=<span class="ruby-keyword">false</span>
|
374
|
+
<span class="ruby-ivar">@built</span>=<span class="ruby-keyword">false</span>
|
375
|
+
<span class="ruby-keyword">end</span>
|
376
|
+
<span class="ruby-ivar">@closed</span> = <span class="ruby-keyword">true</span>
|
377
|
+
<span class="ruby-keyword">end</span></pre>
|
378
|
+
</div><!-- close_apps-source -->
|
379
|
+
|
380
|
+
</div>
|
381
|
+
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
</div><!-- close_apps-method -->
|
386
|
+
|
387
|
+
|
388
|
+
<div id="method-i-closecir" class="method-detail ">
|
389
|
+
|
390
|
+
<div class="method-heading">
|
391
|
+
<span class="method-name">closecir</span><span
|
392
|
+
class="method-args">()</span>
|
393
|
+
<span class="method-click-advice">click to toggle source</span>
|
394
|
+
</div>
|
395
|
+
|
396
|
+
|
397
|
+
<div class="method-description">
|
398
|
+
|
399
|
+
<p>Closes the circuit</p>
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
<div class="method-source-code" id="closecir-source">
|
404
|
+
<pre><span class="ruby-comment"># File lib/circuits.rb, line 146</span>
|
405
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">closecir</span>
|
406
|
+
<span class="ruby-ivar">@torcontroller</span>.<span class="ruby-identifier">closecircuit</span>(<span class="ruby-ivar">@cirnum</span>) <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span> <span class="ruby-ivar">@cirnum</span>.<span class="ruby-identifier">nil?</span>
|
407
|
+
<span class="ruby-ivar">@built</span>=<span class="ruby-keyword">false</span>
|
408
|
+
<span class="ruby-keyword">end</span></pre>
|
409
|
+
</div><!-- closecir-source -->
|
410
|
+
|
411
|
+
</div>
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
|
416
|
+
</div><!-- closecir-method -->
|
417
|
+
|
418
|
+
|
419
|
+
<div id="method-i-closed-3F" class="method-detail ">
|
420
|
+
|
421
|
+
<div class="method-heading">
|
422
|
+
<span class="method-name">closed?</span><span
|
423
|
+
class="method-args">()</span>
|
424
|
+
<span class="method-click-advice">click to toggle source</span>
|
425
|
+
</div>
|
426
|
+
|
427
|
+
|
428
|
+
<div class="method-description">
|
429
|
+
|
430
|
+
<p>Checks if the application instances for <a href="../Tor.html">Tor</a> and
|
431
|
+
polipo have been closed</p>
|
432
|
+
|
433
|
+
|
434
|
+
|
435
|
+
<div class="method-source-code" id="closed-3F-source">
|
436
|
+
<pre><span class="ruby-comment"># File lib/circuits.rb, line 41</span>
|
437
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">closed?</span>
|
438
|
+
<span class="ruby-ivar">@closed</span>
|
439
|
+
<span class="ruby-keyword">end</span></pre>
|
440
|
+
</div><!-- closed-3F-source -->
|
441
|
+
|
442
|
+
</div>
|
443
|
+
|
444
|
+
|
445
|
+
|
446
|
+
|
447
|
+
</div><!-- closed-3F-method -->
|
448
|
+
|
449
|
+
|
450
|
+
<div id="method-i-controller" class="method-detail ">
|
451
|
+
|
452
|
+
<div class="method-heading">
|
453
|
+
<span class="method-name">controller</span><span
|
454
|
+
class="method-args">()</span>
|
455
|
+
<span class="method-click-advice">click to toggle source</span>
|
456
|
+
</div>
|
457
|
+
|
458
|
+
|
459
|
+
<div class="method-description">
|
460
|
+
|
461
|
+
<p>Returns the Tor:Controller used for the circuit.</p>
|
462
|
+
|
463
|
+
|
464
|
+
|
465
|
+
<div class="method-source-code" id="controller-source">
|
466
|
+
<pre><span class="ruby-comment"># File lib/circuits.rb, line 29</span>
|
467
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">controller</span>
|
468
|
+
<span class="ruby-keyword">if</span> <span class="ruby-keyword">defined?</span>(<span class="ruby-ivar">@torcontroller</span>)
|
469
|
+
<span class="ruby-ivar">@torcontroller</span>
|
470
|
+
<span class="ruby-keyword">end</span>
|
471
|
+
<span class="ruby-keyword">end</span></pre>
|
472
|
+
</div><!-- controller-source -->
|
473
|
+
|
474
|
+
</div>
|
475
|
+
|
476
|
+
|
477
|
+
|
478
|
+
|
479
|
+
</div><!-- controller-method -->
|
480
|
+
|
481
|
+
|
482
|
+
<div id="method-i-extend" class="method-detail ">
|
483
|
+
|
484
|
+
<div class="method-heading">
|
485
|
+
<span class="method-name">extend</span><span
|
486
|
+
class="method-args">()</span>
|
487
|
+
<span class="method-click-advice">click to toggle source</span>
|
488
|
+
</div>
|
489
|
+
|
490
|
+
|
491
|
+
<div class="method-description">
|
492
|
+
|
493
|
+
<p>This creates / builds the actual circuit using @circuitarray.</p>
|
494
|
+
|
495
|
+
|
496
|
+
|
497
|
+
<div class="method-source-code" id="extend-source">
|
498
|
+
<pre><span class="ruby-comment"># File lib/circuits.rb, line 46</span>
|
499
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">extend</span>
|
500
|
+
<span class="ruby-keyword">if</span> <span class="ruby-keyword">defined?</span>(<span class="ruby-ivar">@torcontroller</span>)
|
501
|
+
<span class="ruby-ivar">@cirnum</span> = <span class="ruby-ivar">@torcontroller</span>.<span class="ruby-identifier">extendcir</span>(<span class="ruby-value">0</span>,<span class="ruby-ivar">@circuitarray</span>)
|
502
|
+
<span class="ruby-keyword">else</span>
|
503
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-string">"launch before extending\n"</span>
|
504
|
+
<span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span>
|
505
|
+
<span class="ruby-keyword">end</span>
|
506
|
+
<span class="ruby-keyword">end</span></pre>
|
507
|
+
</div><!-- extend-source -->
|
508
|
+
|
509
|
+
</div>
|
510
|
+
|
511
|
+
|
512
|
+
|
513
|
+
|
514
|
+
</div><!-- extend-method -->
|
515
|
+
|
516
|
+
|
517
|
+
<div id="method-i-get_bridges" class="method-detail ">
|
518
|
+
|
519
|
+
<div class="method-heading">
|
520
|
+
<span class="method-name">get_bridges</span><span
|
521
|
+
class="method-args">(cacheddesc, *config)</span>
|
522
|
+
<span class="method-click-advice">click to toggle source</span>
|
523
|
+
</div>
|
524
|
+
|
525
|
+
|
526
|
+
<div class="method-description">
|
527
|
+
|
528
|
+
<p>This gets 3 bridge IP addresses from the <a href="../Tor.html">Tor</a>
|
529
|
+
bridge website. proxyconfig is optional. default proxyconfig =
|
530
|
+
{:type=>‘polipo’ ,:port=>8118,:addr=>‘127.0.0.1’} The return
|
531
|
+
format is fo the form:</p>
|
532
|
+
|
533
|
+
<p>[HTTPcode, [{:bridgeip, :bridgeport},{:bridgeip, :bridgeport},{:bridgeip,
|
534
|
+
:bridgeport}]. The types can be one of ‘tor’, ‘polipo’, ‘socks’, ‘http’,
|
535
|
+
‘https’,nil, ‘none’.</p>
|
536
|
+
|
537
|
+
<p><strong>Get 3 bridges</strong></p>
|
538
|
+
|
539
|
+
<pre class="ruby"><span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">Circuit</span>.<span class="ruby-identifier">get_bridges</span>( <span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">Cacheddesc</span>, {:<span class="ruby-identifier">proxytype=</span><span class="ruby-operator">></span><span class="ruby-string">'polipo'</span>,:<span class="ruby-identifier">proxyport=</span><span class="ruby-operator">></span><span class="ruby-value">8118</span>,:<span class="ruby-identifier">proxyaddr=</span><span class="ruby-operator">></span><span class="ruby-string">'127.0.0.1'</span>} )
|
540
|
+
</pre>
|
541
|
+
|
542
|
+
<p>cachedDesc can be nil if the Google Earth file is not needed.</p>
|
543
|
+
|
544
|
+
|
545
|
+
|
546
|
+
<div class="method-source-code" id="get_bridges-source">
|
547
|
+
<pre><span class="ruby-comment"># File lib/circuits.rb, line 181</span>
|
548
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">get_bridges</span>(<span class="ruby-identifier">cacheddesc</span>, *<span class="ruby-identifier">config</span>)
|
549
|
+
<span class="ruby-identifier">url</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span> <span class="ruby-string">"https://bridges.torproject.org/"</span>
|
550
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">config</span>.<span class="ruby-identifier">empty?</span>
|
551
|
+
<span class="ruby-identifier">proxyconfig</span>={<span class="ruby-value">:type=</span><span class="ruby-operator">></span><span class="ruby-string">'polipo'</span> ,<span class="ruby-value">:port=</span><span class="ruby-operator">></span><span class="ruby-value">8118</span>,<span class="ruby-value">:addr=</span><span class="ruby-operator">></span><span class="ruby-string">'127.0.0.1'</span>}
|
552
|
+
<span class="ruby-keyword">else</span>
|
553
|
+
<span class="ruby-identifier">proxyconfig</span> = <span class="ruby-identifier">config</span>[<span class="ruby-value">0</span>]
|
554
|
+
<span class="ruby-keyword">end</span>
|
555
|
+
|
556
|
+
<span class="ruby-keyword">if</span> <span class="ruby-operator">!</span> <span class="ruby-keyword">defined?</span>(<span class="ruby-ivar">@myhttperrors</span>)
|
557
|
+
<span class="ruby-ivar">@myhttperrors</span>=<span class="ruby-value">0</span>
|
558
|
+
<span class="ruby-keyword">end</span>
|
559
|
+
<span class="ruby-keyword">case</span> <span class="ruby-identifier">proxyconfig</span>[<span class="ruby-value">:type</span>]
|
560
|
+
<span class="ruby-keyword">when</span> <span class="ruby-regexp">/none/</span>,<span class="ruby-keyword">nil</span>
|
561
|
+
<span class="ruby-identifier">http_session</span>=<span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">url</span>.<span class="ruby-identifier">host</span>,<span class="ruby-identifier">url</span>.<span class="ruby-identifier">port</span>)
|
562
|
+
<span class="ruby-keyword">when</span> <span class="ruby-regexp">/socks/</span>,<span class="ruby-regexp">/tor/</span>
|
563
|
+
<span class="ruby-identifier">http_session</span>=<span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-constant">SOCKSProxy</span>(<span class="ruby-identifier">proxyconfig</span>[<span class="ruby-value">:addr</span>], <span class="ruby-identifier">proxyconfig</span>[<span class="ruby-value">:port</span>]).<span class="ruby-identifier">new</span>(<span class="ruby-identifier">url</span>.<span class="ruby-identifier">host</span>,<span class="ruby-identifier">url</span>.<span class="ruby-identifier">port</span>)
|
564
|
+
<span class="ruby-keyword">when</span> <span class="ruby-regexp">/http/</span>,<span class="ruby-regexp">/https/</span>,<span class="ruby-regexp">/polipo/</span>
|
565
|
+
<span class="ruby-identifier">http_session</span>=<span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Proxy</span>(<span class="ruby-identifier">proxyconfig</span>[<span class="ruby-value">:addr</span>], <span class="ruby-identifier">proxyconfig</span>[<span class="ruby-value">:port</span>]).<span class="ruby-identifier">new</span>(<span class="ruby-identifier">url</span>.<span class="ruby-identifier">host</span>,<span class="ruby-identifier">url</span>.<span class="ruby-identifier">port</span>)
|
566
|
+
<span class="ruby-keyword">end</span>
|
567
|
+
|
568
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">url</span>.<span class="ruby-identifier">scheme</span><span class="ruby-operator">==</span><span class="ruby-string">"https"</span>
|
569
|
+
<span class="ruby-identifier">http_session</span>.<span class="ruby-identifier">use_ssl</span> = <span class="ruby-keyword">true</span>
|
570
|
+
<span class="ruby-identifier">http_session</span>.<span class="ruby-identifier">verify_mode</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSL</span><span class="ruby-operator">::</span><span class="ruby-constant">VERIFY_NONE</span>
|
571
|
+
<span class="ruby-keyword">else</span>
|
572
|
+
<span class="ruby-identifier">http_session</span>.<span class="ruby-identifier">use_ssl</span>=<span class="ruby-keyword">false</span>
|
573
|
+
<span class="ruby-keyword">end</span>
|
574
|
+
<span class="ruby-identifier">bridges</span>=[]
|
575
|
+
<span class="ruby-comment"># Rescue from http error</span>
|
576
|
+
<span class="ruby-keyword">begin</span>
|
577
|
+
<span class="ruby-identifier">resp</span> = <span class="ruby-identifier">http_session</span>.<span class="ruby-identifier">get2</span> <span class="ruby-identifier">url</span>.<span class="ruby-identifier">path</span> <span class="ruby-comment"># Let Tor choose circuit itself</span>
|
578
|
+
<span class="ruby-comment"># Additional code will be added shortly to attach the stream to the circuit directly</span>
|
579
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"#{resp.code} HTTP response"</span>
|
580
|
+
<span class="ruby-comment"># puts resp.body</span>
|
581
|
+
<span class="ruby-identifier">respcode</span>= <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">code</span><span class="ruby-operator">==</span><span class="ruby-string">"200"</span> <span class="ruby-operator">?</span> <span class="ruby-value">200</span><span class="ruby-operator">:</span><span class="ruby-keyword">nil</span>
|
582
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">code</span> <span class="ruby-operator">==</span> <span class="ruby-string">"200"</span>
|
583
|
+
<span class="ruby-identifier">torbridgeip</span>=<span class="ruby-identifier">resp</span>.<span class="ruby-identifier">body</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp">/\d+\.\d+\.\d+\.\d+\:\d+/</span>)
|
584
|
+
<span class="ruby-identifier">torbridgeip</span>.<span class="ruby-identifier">each</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">eachbridge</span><span class="ruby-operator">|</span>
|
585
|
+
<span class="ruby-identifier">bridgeip</span>,<span class="ruby-identifier">bridgeport</span>= <span class="ruby-identifier">eachbridge</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">':'</span>)
|
586
|
+
<span class="ruby-identifier">x</span> = <span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">Bridge</span>.<span class="ruby-identifier">where</span>(<span class="ruby-value">:ipaddr=</span><span class="ruby-operator">></span><span class="ruby-identifier">bridgeip</span>, <span class="ruby-value">:port</span> =<span class="ruby-operator">></span><span class="ruby-identifier">bridgeport</span>)
|
587
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">empty?</span>
|
588
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">cacheddesc</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword">or</span> (<span class="ruby-identifier">bridge_geoip</span> = <span class="ruby-identifier">cacheddesc</span>.<span class="ruby-identifier">get_geoiprecord</span>(<span class="ruby-identifier">bridgeip</span>)).<span class="ruby-identifier">nil?</span>
|
589
|
+
<span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">Bridge</span>.<span class="ruby-identifier">create</span>(<span class="ruby-value">:ipaddr=</span><span class="ruby-operator">></span><span class="ruby-identifier">bridgeip</span>, <span class="ruby-value">:port</span> =<span class="ruby-operator">></span><span class="ruby-identifier">bridgeport</span>,
|
590
|
+
<span class="ruby-value">:lat=</span><span class="ruby-operator">></span><span class="ruby-value">0</span>, <span class="ruby-value">:lng=</span><span class="ruby-operator">></span><span class="ruby-value">0</span>)
|
591
|
+
<span class="ruby-keyword">else</span>
|
592
|
+
<span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">Bridge</span>.<span class="ruby-identifier">create</span>(<span class="ruby-value">:ipaddr=</span><span class="ruby-operator">></span><span class="ruby-identifier">bridgeip</span>, <span class="ruby-value">:port</span> =<span class="ruby-operator">></span><span class="ruby-identifier">bridgeport</span>,
|
593
|
+
<span class="ruby-value">:lat=</span><span class="ruby-operator">></span><span class="ruby-identifier">bridge_geoip</span>.<span class="ruby-identifier">latitude</span>.<span class="ruby-identifier">to_f</span>,
|
594
|
+
<span class="ruby-value">:lng=</span><span class="ruby-operator">></span><span class="ruby-identifier">bridge_geoip</span>.<span class="ruby-identifier">longitude</span>.<span class="ruby-identifier">to_f</span> )
|
595
|
+
<span class="ruby-keyword">end</span>
|
596
|
+
<span class="ruby-keyword">end</span>
|
597
|
+
}
|
598
|
+
<span class="ruby-keyword">end</span>
|
599
|
+
<span class="ruby-identifier">bridges</span> = <span class="ruby-identifier">torbridgeip</span>
|
600
|
+
<span class="ruby-keyword">rescue</span>
|
601
|
+
<span class="ruby-ivar">@myhttperrors</span> <span class="ruby-operator">+=</span><span class="ruby-value">1</span>
|
602
|
+
<span class="ruby-identifier">respcode</span>=<span class="ruby-keyword">nil</span>
|
603
|
+
<span class="ruby-identifier">bridges</span>=[]
|
604
|
+
<span class="ruby-keyword">end</span>
|
605
|
+
<span class="ruby-identifier">bridges</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">?</span> [] <span class="ruby-operator">:</span> <span class="ruby-identifier">bridges</span> <span class="ruby-comment">#Return array of all bridges</span>
|
606
|
+
<span class="ruby-keyword">end</span></pre>
|
607
|
+
</div><!-- get_bridges-source -->
|
608
|
+
|
609
|
+
</div>
|
610
|
+
|
611
|
+
|
612
|
+
|
613
|
+
|
614
|
+
</div><!-- get_bridges-method -->
|
615
|
+
|
616
|
+
|
617
|
+
<div id="method-i-launch" class="method-detail ">
|
618
|
+
|
619
|
+
<div class="method-heading">
|
620
|
+
<span class="method-name">launch</span><span
|
621
|
+
class="method-args">()</span>
|
622
|
+
<span class="method-click-advice">click to toggle source</span>
|
623
|
+
</div>
|
624
|
+
|
625
|
+
|
626
|
+
<div class="method-description">
|
627
|
+
|
628
|
+
<p>Run this after initializing a <a href="Circuit.html">Tor::Circuit</a>
|
629
|
+
instaance. This writes the following <a href="../Tor.html">Tor</a>
|
630
|
+
configuration options to a temp file if proxyport not nil: Write HttpProxy,
|
631
|
+
HttpsProxy , DataDirectory /tmp/dir, __LeaveStreamUnattached 1. This also
|
632
|
+
writes polipoo configuration to a temporary file and executes polipo It
|
633
|
+
executes <a href="../Tor.html">Tor</a> and polipo if proxyport is not nil
|
634
|
+
Note: The applicaitons will continue running even if the ruby shell is
|
635
|
+
exited. The <a href="Circuit.html#method-i-close_apps">#close_apps</a>
|
636
|
+
method can be used to terminate the application and remove the temp dir</p>
|
637
|
+
|
638
|
+
|
639
|
+
|
640
|
+
<div class="method-source-code" id="launch-source">
|
641
|
+
<pre><span class="ruby-comment"># File lib/circuits.rb, line 93</span>
|
642
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">launch</span>
|
643
|
+
<span class="ruby-comment"># should I use popen3? dont need stdin and stderror from tor or polipo</span>
|
644
|
+
<span class="ruby-keyword">if</span> <span class="ruby-operator">!</span> <span class="ruby-ivar">@proxyconfig</span>.<span class="ruby-identifier">nil?</span>
|
645
|
+
<span class="ruby-ivar">@path</span> = <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">mktmpdir</span> <span class="ruby-keyword">if</span> <span class="ruby-keyword">not</span> <span class="ruby-keyword">defined?</span>(<span class="ruby-ivar">@path</span>)
|
646
|
+
<span class="ruby-ivar">@pid</span>= {}
|
647
|
+
<span class="ruby-identifier">torrc_filename</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@path</span>,<span class="ruby-string">"torrc"</span>)
|
648
|
+
<span class="ruby-identifier">torrc</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">torrc_filename</span>, <span class="ruby-string">"w"</span>)
|
649
|
+
<span class="ruby-comment"># populate torrc</span>
|
650
|
+
<span class="ruby-identifier">socks_port</span> = <span class="ruby-ivar">@ctrller_config</span>[<span class="ruby-value">:port</span>] <span class="ruby-operator">-</span> <span class="ruby-value">1</span>
|
651
|
+
<span class="ruby-identifier">torrc</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"ControlPort #{@ctrller_config[:port]}\n"</span>
|
652
|
+
<span class="ruby-identifier">torrc</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"DataDirectory #{@path}\n"</span>
|
653
|
+
<span class="ruby-identifier">torrc</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"HttpProxy 127.0.0.1:#{@proxyconfig - 1}\n"</span> <span class="ruby-comment"># Use the preceeding polipo port</span>
|
654
|
+
<span class="ruby-identifier">torrc</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"HttpsProxy 127.0.0.1:#{@proxyconfig - 1}\n"</span>
|
655
|
+
<span class="ruby-identifier">torrc</span>.<span class="ruby-identifier">puts</span> <span class="ruby-string">"RunAsDaemon 1\n"</span>
|
656
|
+
<span class="ruby-identifier">torrc</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"SocksPort #{socks_port}\n"</span>
|
657
|
+
<span class="ruby-identifier">torrc</span>.<span class="ruby-identifier">puts</span> <span class="ruby-string">"SocksListenAddress 127.0.0.1\n"</span>
|
658
|
+
<span class="ruby-comment"># can add a random password and call tor --hashcontrolpassword read stdout..but feels like long thing. Or ruby implementation of hash</span>
|
659
|
+
<span class="ruby-identifier">torrc</span>.<span class="ruby-identifier">close</span>
|
660
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-string">"Torrc config written \n"</span>
|
661
|
+
<span class="ruby-comment">#puts @tor_io=Process.spawn("tor","-f",torrc_filename) # stdin, stdout, stderr, thread</span>
|
662
|
+
<span class="ruby-comment">#puts @tor_io=Open3.popen3("tor","-f",torrc_filename) # stdin, stdout, stderr, thread</span>
|
663
|
+
<span class="ruby-ivar">@pid</span>[<span class="ruby-value">:tor</span>] = <span class="ruby-constant">Process</span>.<span class="ruby-identifier">spawn</span>(<span class="ruby-string">"tor"</span>,<span class="ruby-string">"-f"</span>,<span class="ruby-identifier">torrc_filename</span>)
|
664
|
+
<span class="ruby-identifier">sleep</span>(<span class="ruby-value">7</span>) <span class="ruby-comment"># wait 7 seconds to download cached consensus and descriptors. -Consider copuing the existing one from the previous directory</span>
|
665
|
+
<span class="ruby-comment"># check here # **************** why sleep? can I use the cached desc from the first tor process</span>
|
666
|
+
<span class="ruby-ivar">@torcontroller</span> = <span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">TController</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@ctrller_config</span>)
|
667
|
+
<span class="ruby-comment"># write proxyconfig to polipo</span>
|
668
|
+
<span class="ruby-identifier">polipo_filename</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@path</span>,<span class="ruby-string">"polipo_config"</span>)
|
669
|
+
<span class="ruby-identifier">polipo_config</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">polipo_filename</span> , <span class="ruby-string">"w"</span>)
|
670
|
+
<span class="ruby-identifier">polipo_config</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"proxyPort = #{@proxyconfig}\n"</span>
|
671
|
+
<span class="ruby-identifier">polipo_config</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"socksParentProxy = localhost:#{socks_port}\n"</span>
|
672
|
+
<span class="ruby-identifier">polipo_config</span>.<span class="ruby-identifier">puts</span> <span class="ruby-string">"socksProxyType = socks5\n"</span>
|
673
|
+
<span class="ruby-identifier">polipo_config</span>.<span class="ruby-identifier">puts</span> <span class="ruby-string">"daemonise = true\n"</span>
|
674
|
+
<span class="ruby-identifier">polipo_log</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@path</span>,<span class="ruby-string">"polipo_log"</span>)
|
675
|
+
<span class="ruby-identifier">polipo_pid</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@path</span>,<span class="ruby-string">"polipo.pid"</span>)
|
676
|
+
<span class="ruby-identifier">polipo_forbid</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@path</span>,<span class="ruby-string">"forbidden"</span>)
|
677
|
+
<span class="ruby-identifier">polipo_config</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"logFile = #{polipo_log}\n"</span>
|
678
|
+
<span class="ruby-identifier">polipo_config</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"pidFile = #{polipo_pid}\n"</span>
|
679
|
+
<span class="ruby-identifier">polipo_config</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"forbiddenFile = #{polipo_forbid}\n"</span>
|
680
|
+
<span class="ruby-identifier">polipo_config</span>.<span class="ruby-identifier">close</span>
|
681
|
+
<span class="ruby-ivar">@pid</span>[<span class="ruby-value">:polipo</span>]= <span class="ruby-constant">Process</span>.<span class="ruby-identifier">spawn</span>( <span class="ruby-string">"polipo"</span>, <span class="ruby-string">"-c"</span>, <span class="ruby-identifier">polipo_filename</span>)
|
682
|
+
<span class="ruby-keyword">end</span>
|
683
|
+
<span class="ruby-ivar">@torcontroller</span> = <span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">TController</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@ctrller_config</span>)
|
684
|
+
<span class="ruby-comment"># @path = @torcontroller.getconf("DataDirectory") when proxyconfig==nil # dont need path for the first Tor</span>
|
685
|
+
<span class="ruby-ivar">@torcontroller</span>.<span class="ruby-identifier">setconf</span>(<span class="ruby-string">"__DisablePredictedCircuits"</span>,<span class="ruby-value">1</span>)
|
686
|
+
<span class="ruby-ivar">@torcontroller</span>.<span class="ruby-identifier">setconf</span>(<span class="ruby-string">"newcircuitperiod"</span>,<span class="ruby-value">999999999</span>)
|
687
|
+
<span class="ruby-ivar">@torcontroller</span>.<span class="ruby-identifier">setconf</span>(<span class="ruby-string">"maxcircuitdirtiness"</span>,<span class="ruby-value">999999999</span>)
|
688
|
+
<span class="ruby-ivar">@torcontroller</span>.<span class="ruby-identifier">setconf</span>(<span class="ruby-string">"MaxOnionsPending"</span>,<span class="ruby-value">0</span>)
|
689
|
+
<span class="ruby-ivar">@torcontroller</span>.<span class="ruby-identifier">setconf</span>(<span class="ruby-string">"__LeaveStreamsUnattached"</span>,<span class="ruby-value">1</span>)
|
690
|
+
<span class="ruby-ivar">@launched</span> = <span class="ruby-keyword">true</span>
|
691
|
+
<span class="ruby-ivar">@closed</span> = <span class="ruby-keyword">false</span>
|
692
|
+
<span class="ruby-keyword">end</span></pre>
|
693
|
+
</div><!-- launch-source -->
|
694
|
+
|
695
|
+
</div>
|
696
|
+
|
697
|
+
|
698
|
+
|
699
|
+
|
700
|
+
</div><!-- launch-method -->
|
701
|
+
|
702
|
+
|
703
|
+
<div id="method-i-launched-3F" class="method-detail ">
|
704
|
+
|
705
|
+
<div class="method-heading">
|
706
|
+
<span class="method-name">launched?</span><span
|
707
|
+
class="method-args">()</span>
|
708
|
+
<span class="method-click-advice">click to toggle source</span>
|
709
|
+
</div>
|
710
|
+
|
711
|
+
|
712
|
+
<div class="method-description">
|
713
|
+
|
714
|
+
<p>Checks if the launched method has been called</p>
|
715
|
+
|
716
|
+
|
717
|
+
|
718
|
+
<div class="method-source-code" id="launched-3F-source">
|
719
|
+
<pre><span class="ruby-comment"># File lib/circuits.rb, line 85</span>
|
720
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">launched?</span>
|
721
|
+
<span class="ruby-ivar">@launched</span>
|
722
|
+
<span class="ruby-keyword">end</span></pre>
|
723
|
+
</div><!-- launched-3F-source -->
|
724
|
+
|
725
|
+
</div>
|
726
|
+
|
727
|
+
|
728
|
+
|
729
|
+
|
730
|
+
</div><!-- launched-3F-method -->
|
731
|
+
|
732
|
+
|
733
|
+
<div id="method-i-start" class="method-detail ">
|
734
|
+
|
735
|
+
<div class="method-heading">
|
736
|
+
<span class="method-name">start</span><span
|
737
|
+
class="method-args">()</span>
|
738
|
+
<span class="method-click-advice">click to toggle source</span>
|
739
|
+
</div>
|
740
|
+
|
741
|
+
|
742
|
+
<div class="method-description">
|
743
|
+
|
744
|
+
<p>This attaches all streams on this controller to a prebuilt circuit that has
|
745
|
+
been</p>
|
746
|
+
|
747
|
+
|
748
|
+
|
749
|
+
<div class="method-source-code" id="start-source">
|
750
|
+
<pre><span class="ruby-comment"># File lib/circuits.rb, line 56</span>
|
751
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">start</span>
|
752
|
+
<span class="ruby-keyword">if</span> <span class="ruby-operator">!</span> <span class="ruby-identifier">launched?</span>
|
753
|
+
<span class="ruby-identifier">launch</span>
|
754
|
+
<span class="ruby-keyword">end</span>
|
755
|
+
<span class="ruby-keyword">if</span> <span class="ruby-operator">!</span> <span class="ruby-identifier">built?</span>
|
756
|
+
<span class="ruby-identifier">extend</span>
|
757
|
+
<span class="ruby-keyword">end</span>
|
758
|
+
<span class="ruby-comment"># sleep(3.5) ###################### wait 3 seconds before checking if built. # May not be needed</span>
|
759
|
+
<span class="ruby-comment"># use events here instead to (build) no matter what. or (launch and build). If built, attach existing streams from preceeding subcircuit</span>
|
760
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">built?</span>
|
761
|
+
<span class="ruby-identifier">streams_array</span> = <span class="ruby-ivar">@torcontroller</span>.<span class="ruby-identifier">newstreams</span>
|
762
|
+
<span class="ruby-keyword">if</span> <span class="ruby-operator">!</span> <span class="ruby-identifier">streams_array</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword">and</span> <span class="ruby-operator">!</span> <span class="ruby-ivar">@cirnum</span>.<span class="ruby-identifier">nil?</span>
|
763
|
+
<span class="ruby-identifier">streams_array</span>.<span class="ruby-identifier">each</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">each_stream</span><span class="ruby-operator">|</span>
|
764
|
+
<span class="ruby-ivar">@torcontroller</span>.<span class="ruby-identifier">attach_stream</span>(<span class="ruby-identifier">each_stream</span>, <span class="ruby-ivar">@cirnum</span>)
|
765
|
+
}
|
766
|
+
<span class="ruby-keyword">end</span>
|
767
|
+
<span class="ruby-keyword">end</span>
|
768
|
+
<span class="ruby-keyword">end</span></pre>
|
769
|
+
</div><!-- start-source -->
|
770
|
+
|
771
|
+
</div>
|
772
|
+
|
773
|
+
|
774
|
+
|
775
|
+
|
776
|
+
</div><!-- start-method -->
|
777
|
+
|
778
|
+
|
779
|
+
</section><!-- public-instance-method-details -->
|
780
|
+
|
781
|
+
</section><!-- 5Buntitled-5D -->
|
782
|
+
|
783
|
+
</div><!-- documentation -->
|
784
|
+
|
785
|
+
|
786
|
+
<footer id="validator-badges">
|
787
|
+
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
788
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.11.
|
789
|
+
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
790
|
+
</footer>
|
791
|
+
|