tor_extend 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. data/Change.log +12 -0
  2. data/ReadME.txt +190 -0
  3. data/doc/ReadME_txt.html +301 -0
  4. data/doc/Tor.html +140 -0
  5. data/doc/Tor/Bridge.html +145 -0
  6. data/doc/Tor/CachedDesc.html +472 -0
  7. data/doc/Tor/Constants.html +185 -0
  8. data/doc/Tor/Router.html +146 -0
  9. data/doc/Tor/StatsObj.html +1209 -0
  10. data/doc/Tor/TController.html +1111 -0
  11. data/doc/created.rid +7 -0
  12. data/doc/images/add.png +0 -0
  13. data/doc/images/brick.png +0 -0
  14. data/doc/images/brick_link.png +0 -0
  15. data/doc/images/bug.png +0 -0
  16. data/doc/images/bullet_black.png +0 -0
  17. data/doc/images/bullet_toggle_minus.png +0 -0
  18. data/doc/images/bullet_toggle_plus.png +0 -0
  19. data/doc/images/date.png +0 -0
  20. data/doc/images/delete.png +0 -0
  21. data/doc/images/find.png +0 -0
  22. data/doc/images/loadingAnimation.gif +0 -0
  23. data/doc/images/macFFBgHack.png +0 -0
  24. data/doc/images/package.png +0 -0
  25. data/doc/images/page_green.png +0 -0
  26. data/doc/images/page_white_text.png +0 -0
  27. data/doc/images/page_white_width.png +0 -0
  28. data/doc/images/plugin.png +0 -0
  29. data/doc/images/ruby.png +0 -0
  30. data/doc/images/tag_blue.png +0 -0
  31. data/doc/images/tag_green.png +0 -0
  32. data/doc/images/transparent.png +0 -0
  33. data/doc/images/wrench.png +0 -0
  34. data/doc/images/wrench_orange.png +0 -0
  35. data/doc/images/zoom.png +0 -0
  36. data/doc/index.html +90 -0
  37. data/doc/js/darkfish.js +153 -0
  38. data/doc/js/jquery.js +18 -0
  39. data/doc/js/navigation.js +142 -0
  40. data/doc/js/search.js +94 -0
  41. data/doc/js/search_index.js +1 -0
  42. data/doc/js/searcher.js +228 -0
  43. data/doc/lib/constants_rb.html +96 -0
  44. data/doc/lib/httpmod_rb.html +95 -0
  45. data/doc/lib/tcontroller_rb.html +93 -0
  46. data/doc/lib/tor_extend_rb.html +97 -0
  47. data/doc/lib/tstats_rb.html +93 -0
  48. data/doc/rdoc.css +543 -0
  49. data/doc/table_of_contents.html +159 -0
  50. data/lib/constants.rb +106 -0
  51. data/lib/httpmod.rb +89 -0
  52. data/lib/tcontroller.rb +475 -0
  53. data/lib/tor_extend.rb +189 -0
  54. data/lib/tstats.rb +514 -0
  55. data/tor_extend.gemspec +26 -0
  56. metadata +138 -0
@@ -0,0 +1,185 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
6
+
7
+ <title>Module: Tor::Constants</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="module">
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/constants.rb
51
+ </ul>
52
+ </nav>
53
+
54
+
55
+ </div>
56
+
57
+ <div id="class-metadata">
58
+
59
+
60
+
61
+
62
+ </div>
63
+
64
+ <div id="project-metadata">
65
+ <nav id="fileindex-section" class="section project-section">
66
+ <h3 class="section-header">Pages</h3>
67
+
68
+ <ul>
69
+
70
+ <li class="file"><a href="../ReadME_txt.html">ReadME</a>
71
+
72
+ </ul>
73
+ </nav>
74
+
75
+ <nav id="classindex-section" class="section project-section">
76
+ <h3 class="section-header">Class and Module Index</h3>
77
+
78
+ <ul class="link-list">
79
+
80
+ <li><a href="../Tor.html">Tor</a>
81
+
82
+ <li><a href="../Tor/Bridge.html">Tor::Bridge</a>
83
+
84
+ <li><a href="../Tor/CachedDesc.html">Tor::CachedDesc</a>
85
+
86
+ <li><a href="../Tor/Constants.html">Tor::Constants</a>
87
+
88
+ <li><a href="../Tor/Router.html">Tor::Router</a>
89
+
90
+ <li><a href="../Tor/StatsObj.html">Tor::StatsObj</a>
91
+
92
+ <li><a href="../Tor/TController.html">Tor::TController</a>
93
+
94
+ </ul>
95
+ </nav>
96
+
97
+ </div>
98
+ </nav>
99
+
100
+ <div id="documentation">
101
+ <h1 class="module">module Tor::Constants</h1>
102
+
103
+ <div id="description" class="description">
104
+
105
+ <p>This module contains constants for the <a href="../Tor.html">Tor</a> module
106
+ such as a <a href="Constants.html#COUNLATLNG">COUNLATLNG</a></p>
107
+
108
+ </div><!-- description -->
109
+
110
+
111
+
112
+
113
+ <section id="5Buntitled-5D" class="documentation-section">
114
+
115
+
116
+
117
+
118
+
119
+ <!-- Constants -->
120
+ <section id="constants-list" class="section">
121
+ <h3 class="section-header">Constants</h3>
122
+ <dl>
123
+
124
+ <dt id="ATTACK_TOUR">ATTACK_TOUR
125
+
126
+ <dd class="description"><p>FR1 is the centre, by default, centres 1 to 90 are read by default, and
127
+ 91-200 change to black after 2seconds This can be changed using a the
128
+ mix-in features of Ruby, using the keys {:lat , :lng,“red”, “black”}</p>
129
+
130
+
131
+ <dt id="COUNLATLNG">COUNLATLNG
132
+
133
+ <dd class="description"><p>This maps the coordinates of each country to its country code.</p>
134
+
135
+ <p><strong>Get</strong> <strong>Coordinates</strong> <strong>for</strong>
136
+ <strong>countries</strong></p>
137
+
138
+ <pre class="ruby"><span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">Constants</span><span class="ruby-operator">::</span><span class="ruby-constant">COUNLATLNG</span>[<span class="ruby-string">&quot;FR&quot;</span>] =<span class="ruby-operator">&gt;</span>{:<span class="ruby-identifier">lat=</span><span class="ruby-operator">&gt;</span><span class="ruby-value">46.0</span>, :<span class="ruby-identifier">lng=</span><span class="ruby-operator">&gt;</span><span class="ruby-value">2.0</span>}
139
+ <span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">Constants</span><span class="ruby-operator">::</span><span class="ruby-constant">COUNLATLNG</span>[<span class="ruby-string">&quot;GB&quot;</span>] =<span class="ruby-operator">&gt;</span>{:<span class="ruby-identifier">lat=</span><span class="ruby-operator">&gt;</span><span class="ruby-value">54.0</span>, :<span class="ruby-identifier">lng=</span><span class="ruby-operator">&gt;</span><span class="ruby-value">-2.0</span>}
140
+ <span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">Constants</span><span class="ruby-operator">::</span><span class="ruby-constant">COUNLATLNG</span>[<span class="ruby-string">&quot;FR&quot;</span>][:<span class="ruby-identifier">lat</span>] =<span class="ruby-operator">&gt;</span><span class="ruby-value">46.0</span>
141
+ <span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">Constants</span><span class="ruby-operator">::</span><span class="ruby-constant">COUNLATLNG</span>[<span class="ruby-string">&quot;GB&quot;</span>][<span class="ruby-identifier">lng</span>] =<span class="ruby-operator">&gt;</span><span class="ruby-value">-2.0</span>
142
+ </pre>
143
+
144
+ <p>A1 and A2 - anonymous proxies and satelite providers - added using
145
+ cordinates (0,0) IM, AX, JE added from the CIA factbook, the others from
146
+ the Maxmind page <strong>NOTE:</strong> See the following links for more
147
+ details CIA Factbook online [<a
148
+ href="https://www.cia.gov/library/publications/the-world-factbook/fields/2011.html">www.cia.gov/library/publications/the-world-factbook/fields/2011.html</a>]
149
+ Maxmind(2007) - Average Latitude and longitude for countries [<a
150
+ href="http://www.maxmind.com/app/country_latlon">www.maxmind.com/app/country_latlon</a>]</p>
151
+
152
+
153
+ <dt id="EXTEND_DELAY">EXTEND_DELAY
154
+
155
+ <dd class="description"><p>This determines how long the program <a
156
+ href="TController.html#method-i-extendcir_slowly">Tor::TController#extendcir_slowly</a>
157
+ waits between each extension.</p>
158
+
159
+
160
+ <dt id="WORLDTOUR">WORLDTOUR
161
+
162
+ <dd class="description"><p>This determines where the tour goes to and which placemark ballons come up
163
+ centres: South Africa, Benin, Switz, Ukraine, India, Australia, Paraguay,
164
+ United States,France</p>
165
+
166
+
167
+ </dl>
168
+ </section>
169
+
170
+
171
+
172
+
173
+ <!-- Methods -->
174
+
175
+ </section><!-- 5Buntitled-5D -->
176
+
177
+ </div><!-- documentation -->
178
+
179
+
180
+ <footer id="validator-badges">
181
+ <p><a href="http://validator.w3.org/check/referer">[Validate]</a>
182
+ <p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.11.
183
+ <p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
184
+ </footer>
185
+
@@ -0,0 +1,146 @@
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::Router</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/tor_extend.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">ActiveRecord::Base
63
+
64
+ </nav>
65
+
66
+
67
+
68
+ </div>
69
+
70
+ <div id="project-metadata">
71
+ <nav id="fileindex-section" class="section project-section">
72
+ <h3 class="section-header">Pages</h3>
73
+
74
+ <ul>
75
+
76
+ <li class="file"><a href="../ReadME_txt.html">ReadME</a>
77
+
78
+ </ul>
79
+ </nav>
80
+
81
+ <nav id="classindex-section" class="section project-section">
82
+ <h3 class="section-header">Class and Module Index</h3>
83
+
84
+ <ul class="link-list">
85
+
86
+ <li><a href="../Tor.html">Tor</a>
87
+
88
+ <li><a href="../Tor/Bridge.html">Tor::Bridge</a>
89
+
90
+ <li><a href="../Tor/CachedDesc.html">Tor::CachedDesc</a>
91
+
92
+ <li><a href="../Tor/Constants.html">Tor::Constants</a>
93
+
94
+ <li><a href="../Tor/Router.html">Tor::Router</a>
95
+
96
+ <li><a href="../Tor/StatsObj.html">Tor::StatsObj</a>
97
+
98
+ <li><a href="../Tor/TController.html">Tor::TController</a>
99
+
100
+ </ul>
101
+ </nav>
102
+
103
+ </div>
104
+ </nav>
105
+
106
+ <div id="documentation">
107
+ <h1 class="class">class Tor::Router</h1>
108
+
109
+ <div id="description" class="description">
110
+
111
+ <p><a href="Router.html">Tor::Router</a> is a class for the active record
112
+ database holding the ip-addresses, platform, fingerprint, country,
113
+ latitude,longitude.</p>
114
+
115
+ <p><strong>Transforming IP address to fingerprint</strong></p>
116
+
117
+ <pre class="ruby"><span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">Router</span>.<span class="ruby-identifier">where</span>(:<span class="ruby-identifier">ipaddr=</span><span class="ruby-operator">&gt;</span><span class="ruby-string">&quot;ipaddr&quot;</span>)[<span class="ruby-value">0</span>].<span class="ruby-identifier">fingerprint</span>
118
+ </pre>
119
+
120
+ </div><!-- description -->
121
+
122
+
123
+
124
+
125
+ <section id="5Buntitled-5D" class="documentation-section">
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+
134
+ <!-- Methods -->
135
+
136
+ </section><!-- 5Buntitled-5D -->
137
+
138
+ </div><!-- documentation -->
139
+
140
+
141
+ <footer id="validator-badges">
142
+ <p><a href="http://validator.w3.org/check/referer">[Validate]</a>
143
+ <p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.11.
144
+ <p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
145
+ </footer>
146
+
@@ -0,0 +1,1209 @@
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::StatsObj</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/tstats.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-i-continent_count">#continent_count</a>
74
+
75
+ <li><a href="#method-i-continent_count_uniq">#continent_count_uniq</a>
76
+
77
+ <li><a href="#method-i-continent_getfingerprint">#continent_getfingerprint</a>
78
+
79
+ <li><a href="#method-i-continent_list">#continent_list</a>
80
+
81
+ <li><a href="#method-i-continent_stat">#continent_stat</a>
82
+
83
+ <li><a href="#method-i-continent_stat_uniq">#continent_stat_uniq</a>
84
+
85
+ <li><a href="#method-i-country_count">#country_count</a>
86
+
87
+ <li><a href="#method-i-country_count_uniq">#country_count_uniq</a>
88
+
89
+ <li><a href="#method-i-country_getfingerprint">#country_getfingerprint</a>
90
+
91
+ <li><a href="#method-i-country_getip">#country_getip</a>
92
+
93
+ <li><a href="#method-i-country_list">#country_list</a>
94
+
95
+ <li><a href="#method-i-country_stat">#country_stat</a>
96
+
97
+ <li><a href="#method-i-country_stat_uniq">#country_stat_uniq</a>
98
+
99
+ <li><a href="#method-i-genkml">#genkml</a>
100
+
101
+ <li><a href="#method-i-get_countryname">#get_countryname</a>
102
+
103
+ <li><a href="#method-i-get_latlng">#get_latlng</a>
104
+
105
+ <li><a href="#method-i-get_uniqid">#get_uniqid</a>
106
+
107
+ <li><a href="#method-i-topcountries">#topcountries</a>
108
+
109
+ <li><a href="#method-i-topcountries_uniq">#topcountries_uniq</a>
110
+
111
+ </ul>
112
+ </nav>
113
+
114
+ </div>
115
+
116
+ <div id="project-metadata">
117
+ <nav id="fileindex-section" class="section project-section">
118
+ <h3 class="section-header">Pages</h3>
119
+
120
+ <ul>
121
+
122
+ <li class="file"><a href="../ReadME_txt.html">ReadME</a>
123
+
124
+ </ul>
125
+ </nav>
126
+
127
+ <nav id="classindex-section" class="section project-section">
128
+ <h3 class="section-header">Class and Module Index</h3>
129
+
130
+ <ul class="link-list">
131
+
132
+ <li><a href="../Tor.html">Tor</a>
133
+
134
+ <li><a href="../Tor/Bridge.html">Tor::Bridge</a>
135
+
136
+ <li><a href="../Tor/CachedDesc.html">Tor::CachedDesc</a>
137
+
138
+ <li><a href="../Tor/Constants.html">Tor::Constants</a>
139
+
140
+ <li><a href="../Tor/Router.html">Tor::Router</a>
141
+
142
+ <li><a href="../Tor/StatsObj.html">Tor::StatsObj</a>
143
+
144
+ <li><a href="../Tor/TController.html">Tor::TController</a>
145
+
146
+ </ul>
147
+ </nav>
148
+
149
+ </div>
150
+ </nav>
151
+
152
+ <div id="documentation">
153
+ <h1 class="class">class Tor::StatsObj</h1>
154
+
155
+ <div id="description" class="description">
156
+
157
+ <p>This class can be used to obtain a variety of statistics or data from <a
158
+ href="Router.html">Tor::Router</a>. The same user have multiple IP
159
+ addresses on different days, but the fingerprint might not change,
160
+ especially not withing a month. Use uniq stats when available.</p>
161
+
162
+ </div><!-- description -->
163
+
164
+
165
+
166
+
167
+ <section id="5Buntitled-5D" class="documentation-section">
168
+
169
+
170
+
171
+
172
+
173
+
174
+
175
+
176
+ <!-- Methods -->
177
+
178
+ <section id="public-instance-5Buntitled-5D-method-details" class="method-section section">
179
+ <h3 class="section-header">Public Instance Methods</h3>
180
+
181
+
182
+ <div id="method-i-continent_count" class="method-detail ">
183
+
184
+ <div class="method-heading">
185
+ <span class="method-name">continent_count</span><span
186
+ class="method-args">(code,*platform)</span>
187
+ <span class="method-click-advice">click to toggle source</span>
188
+ </div>
189
+
190
+
191
+ <div class="method-description">
192
+
193
+ <p>This returns the number of OR IP addresses from the continent with the code
194
+ used as input (and optionally platform parameter).</p>
195
+
196
+ <p>@example Get number of OR IP addr from continents</p>
197
+
198
+ <pre>Tor::StatsObj.continent_count(&quot;EU&quot;)
199
+ Tor::StatsObj.continent_count(&quot;NA&quot;,&quot;UNIX&quot;)
200
+ Tor::StatsObj.continent_count( [&quot;EU&quot;,&quot;NA&quot;,&quot;SA&quot;] ,[ &quot;UNIX&quot;, &quot;LINUX&quot; ] )</pre>
201
+
202
+
203
+
204
+ <div class="method-source-code" id="continent_count-source">
205
+ <pre><span class="ruby-comment"># File lib/tstats.rb, line 67</span>
206
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">continent_count</span>(<span class="ruby-identifier">code</span>,*<span class="ruby-identifier">platform</span>)
207
+ <span class="ruby-identifier">rslt</span> = (<span class="ruby-identifier">platform</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">platform</span> <span class="ruby-operator">==</span> [<span class="ruby-string">&quot;ALL&quot;</span>] ) <span class="ruby-operator">?</span> <span class="ruby-constant">Router</span>.<span class="ruby-identifier">where</span>(<span class="ruby-value">:continent=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">code</span>) <span class="ruby-operator">:</span> <span class="ruby-constant">Router</span>.<span class="ruby-identifier">where</span>(<span class="ruby-value">:continent=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">code</span>, <span class="ruby-value">:platform=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">platform</span>)
208
+ <span class="ruby-identifier">rslt</span>.<span class="ruby-identifier">count</span> <span class="ruby-comment"># continent code &quot;AF&quot;,&quot;EU&quot;,&quot;AS&quot;,&quot;NA&quot;,&quot;SA&quot;,&quot;OC&quot;</span>
209
+ <span class="ruby-keyword">end</span></pre>
210
+ </div><!-- continent_count-source -->
211
+
212
+ </div>
213
+
214
+
215
+
216
+
217
+ </div><!-- continent_count-method -->
218
+
219
+
220
+ <div id="method-i-continent_count_uniq" class="method-detail ">
221
+
222
+ <div class="method-heading">
223
+ <span class="method-name">continent_count_uniq</span><span
224
+ class="method-args">(code,*platform)</span>
225
+ <span class="method-click-advice">click to toggle source</span>
226
+ </div>
227
+
228
+
229
+ <div class="method-description">
230
+
231
+ <p>This returns the number of OR IP addresses from the continent with the code
232
+ used as input (and optionally platform parameter).</p>
233
+
234
+ <p>@example Get number of OR IP addr from continents</p>
235
+
236
+ <pre>Tor::StatsObj.continent_count(&quot;EU&quot;)
237
+ Tor::StatsObj.continent_count(&quot;NA&quot;,&quot;UNIX&quot;)
238
+ Tor::StatsObj.continent_count( [&quot;EU&quot;,&quot;NA&quot;,&quot;SA&quot;] ,[ &quot;UNIX&quot;, &quot;LINUX&quot; ] )</pre>
239
+
240
+
241
+
242
+ <div class="method-source-code" id="continent_count_uniq-source">
243
+ <pre><span class="ruby-comment"># File lib/tstats.rb, line 79</span>
244
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">continent_count_uniq</span>(<span class="ruby-identifier">code</span>,*<span class="ruby-identifier">platform</span>)
245
+ <span class="ruby-identifier">rslt</span> = (<span class="ruby-identifier">platform</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">platform</span> <span class="ruby-operator">==</span> [<span class="ruby-string">&quot;ALL&quot;</span>] ) <span class="ruby-operator">?</span>
246
+ <span class="ruby-constant">Router</span>.<span class="ruby-identifier">where</span>(<span class="ruby-value">:id=</span><span class="ruby-operator">&gt;</span> <span class="ruby-identifier">get_uniqid</span>(<span class="ruby-identifier">country_list</span>, *<span class="ruby-identifier">platform</span>), <span class="ruby-value">:continent=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">code</span>) <span class="ruby-operator">:</span>
247
+ <span class="ruby-constant">Router</span>.<span class="ruby-identifier">where</span>(<span class="ruby-value">:id=</span><span class="ruby-operator">&gt;</span> <span class="ruby-identifier">get_uniqid</span>(<span class="ruby-identifier">country_list</span>, *<span class="ruby-identifier">platform</span>), <span class="ruby-value">:continent=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">code</span>, <span class="ruby-value">:platform=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">platform</span>)
248
+ <span class="ruby-identifier">rslt</span>.<span class="ruby-identifier">count</span> <span class="ruby-comment"># continent code &quot;AF&quot;,&quot;EU&quot;,&quot;AS&quot;,&quot;NA&quot;,&quot;SA&quot;,&quot;OC&quot;</span>
249
+ <span class="ruby-keyword">end</span></pre>
250
+ </div><!-- continent_count_uniq-source -->
251
+
252
+ </div>
253
+
254
+
255
+
256
+
257
+ </div><!-- continent_count_uniq-method -->
258
+
259
+
260
+ <div id="method-i-continent_getfingerprint" class="method-detail ">
261
+
262
+ <div class="method-heading">
263
+ <span class="method-name">continent_getfingerprint</span><span
264
+ class="method-args">(continent_filter,*platform)</span>
265
+ <span class="method-click-advice">click to toggle source</span>
266
+ </div>
267
+
268
+
269
+ <div class="method-description">
270
+
271
+ <p>This retuns an array of all OR fingerprints from <a
272
+ href="Router.html">Tor::Router</a> using a filter of continents and
273
+ optional platform parameter.</p>
274
+
275
+ <p>@example Get all OR IP fingerprints from France</p>
276
+
277
+ <pre>Tor::StatsObj.continent_getfingerprint(&quot;EU&quot;)
278
+ Tor::StatsObj.continent_getfingerprint([&quot;AF&quot;,EU&quot;], &quot;WINDOWS&quot;)
279
+ Tor::StatsObj.continent_getfingerprint([&quot;NA&quot;,&quot;SA&quot;], [&quot;WINDOWS&quot;, &quot;LINUX&quot;] )</pre>
280
+
281
+
282
+
283
+ <div class="method-source-code" id="continent_getfingerprint-source">
284
+ <pre><span class="ruby-comment"># File lib/tstats.rb, line 147</span>
285
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">continent_getfingerprint</span>(<span class="ruby-identifier">continent_filter</span>,*<span class="ruby-identifier">platform</span>)
286
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">platform</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">platform</span> <span class="ruby-operator">==</span> [<span class="ruby-string">&quot;ALL&quot;</span>]
287
+ <span class="ruby-identifier">onionr</span> = <span class="ruby-constant">Router</span>.<span class="ruby-identifier">where</span>(<span class="ruby-value">:continent=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">continent_filter</span>,<span class="ruby-value">:id=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">get_uniqid</span>(<span class="ruby-identifier">countryfilter</span>,*<span class="ruby-identifier">platform</span>))
288
+ <span class="ruby-keyword">else</span>
289
+ <span class="ruby-identifier">onionr</span>=<span class="ruby-constant">Router</span>.<span class="ruby-identifier">where</span>(<span class="ruby-value">:continent=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">continent_filter</span>,<span class="ruby-value">:platform=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">platform</span> ,<span class="ruby-value">:id=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">get_uniqid</span>(<span class="ruby-identifier">countryfilter</span>,*<span class="ruby-identifier">platform</span>))
290
+ <span class="ruby-keyword">end</span>
291
+ <span class="ruby-identifier">onion_ipaddr</span> = <span class="ruby-identifier">onionr</span>.<span class="ruby-identifier">collect</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">each_country</span><span class="ruby-operator">|</span> <span class="ruby-identifier">each_country</span>.<span class="ruby-identifier">fingerprint</span>}
292
+ <span class="ruby-keyword">end</span></pre>
293
+ </div><!-- continent_getfingerprint-source -->
294
+
295
+ </div>
296
+
297
+
298
+
299
+
300
+ </div><!-- continent_getfingerprint-method -->
301
+
302
+
303
+ <div id="method-i-continent_list" class="method-detail ">
304
+
305
+ <div class="method-heading">
306
+ <span class="method-name">continent_list</span><span
307
+ class="method-args">(*platform)</span>
308
+ <span class="method-click-advice">click to toggle source</span>
309
+ </div>
310
+
311
+
312
+ <div class="method-description">
313
+
314
+ <p>This returns a list of all continents that have contributed to the OR IP
315
+ addresses in <a href="Router.html">Tor::Router</a> It can return only the
316
+ those that have contributed to a particular platform</p>
317
+
318
+ <p>@example Get Countries the that use Unix</p>
319
+
320
+ <pre>Tor::StatsObj.continent_list
321
+ Tor::StatsObj.continent_list(&quot;UNIX&quot;)
322
+ Tor::StatsObj.continent_list( [&quot;UNIX&quot;, &quot;LINUX&quot;] )</pre>
323
+
324
+
325
+
326
+ <div class="method-source-code" id="continent_list-source">
327
+ <pre><span class="ruby-comment"># File lib/tstats.rb, line 29</span>
328
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">continent_list</span>(*<span class="ruby-identifier">platform</span>)
329
+ <span class="ruby-identifier">tmpresult</span> = (<span class="ruby-identifier">platform</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">platform</span> <span class="ruby-operator">==</span> [<span class="ruby-string">&quot;ALL&quot;</span>]) <span class="ruby-operator">?</span> <span class="ruby-constant">Router</span>.<span class="ruby-identifier">all</span> <span class="ruby-operator">:</span> <span class="ruby-constant">Router</span>.<span class="ruby-identifier">where</span>(<span class="ruby-value">:platform=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">platform</span>)
330
+ <span class="ruby-identifier">tmpresult</span>.<span class="ruby-identifier">group_by</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">continent</span>}.<span class="ruby-identifier">keys</span>
331
+ <span class="ruby-keyword">end</span></pre>
332
+ </div><!-- continent_list-source -->
333
+
334
+ </div>
335
+
336
+
337
+
338
+
339
+ </div><!-- continent_list-method -->
340
+
341
+
342
+ <div id="method-i-continent_stat" class="method-detail ">
343
+
344
+ <div class="method-heading">
345
+ <span class="method-name">continent_stat</span><span
346
+ class="method-args">(allcontinents,*platform)</span>
347
+ <span class="method-click-advice">click to toggle source</span>
348
+ </div>
349
+
350
+
351
+ <div class="method-description">
352
+
353
+ <p>It takes an array of continent codes as input, and produces a hash with the
354
+ continent codes as keys and the total number of ors from the country as
355
+ value</p>
356
+
357
+ <p>@example Get continents statistics</p>
358
+
359
+ <pre class="ruby"><span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">StatsObj</span>.<span class="ruby-identifier">continent_stat</span>([<span class="ruby-string">&quot;EU&quot;</span>,<span class="ruby-string">&quot;NA&quot;</span>,<span class="ruby-string">&quot;SA&quot;</span>]) =<span class="ruby-operator">&gt;</span> {<span class="ruby-string">&quot;EU&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">total</span>, <span class="ruby-operator">...</span>. <span class="ruby-string">&quot;SA&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">total</span> }
360
+ <span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">StatsObj</span>.<span class="ruby-identifier">continent_stat</span>([<span class="ruby-string">&quot;EU&quot;</span>,<span class="ruby-string">&quot;NA&quot;</span>,<span class="ruby-string">&quot;SA&quot;</span>], <span class="ruby-string">&quot;LINUX&quot;</span>)
361
+ <span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">StatsObj</span>.<span class="ruby-identifier">continent_stat</span>( <span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">StatsObj</span>.<span class="ruby-identifier">country_list</span> )
362
+ </pre>
363
+
364
+ <p>Note: Results of <a
365
+ href="StatsObj.html#method-i-continent_list">#continent_list</a> can be
366
+ used as argument for this <a
367
+ href="StatsObj.html#method-i-continent_stat">#continent_stat</a>.</p>
368
+
369
+
370
+
371
+ <div class="method-source-code" id="continent_stat-source">
372
+ <pre><span class="ruby-comment"># File lib/tstats.rb, line 188</span>
373
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">continent_stat</span>(<span class="ruby-identifier">allcontinents</span>,*<span class="ruby-identifier">platform</span>)
374
+ <span class="ruby-identifier">continent_count_hash</span>={}
375
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">allcontinents</span>.<span class="ruby-identifier">class</span><span class="ruby-operator">==</span><span class="ruby-constant">String</span>
376
+ <span class="ruby-identifier">continent_count_hash</span>[<span class="ruby-identifier">allcontinents</span>] = <span class="ruby-identifier">continent_count</span>(<span class="ruby-identifier">allcontinents</span>,*<span class="ruby-identifier">platform</span>)
377
+ <span class="ruby-keyword">else</span>
378
+ <span class="ruby-identifier">allcontinents</span>.<span class="ruby-identifier">each</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">each_continent</span><span class="ruby-operator">|</span>
379
+ <span class="ruby-identifier">continent_count_hash</span>[<span class="ruby-identifier">each_continent</span>] = <span class="ruby-identifier">continent_count</span>(<span class="ruby-identifier">each_continent</span>,*<span class="ruby-identifier">platform</span>)
380
+ }
381
+ <span class="ruby-keyword">end</span>
382
+ <span class="ruby-identifier">continent_count_hash</span>
383
+ <span class="ruby-keyword">end</span></pre>
384
+ </div><!-- continent_stat-source -->
385
+
386
+ </div>
387
+
388
+
389
+
390
+
391
+ </div><!-- continent_stat-method -->
392
+
393
+
394
+ <div id="method-i-continent_stat_uniq" class="method-detail ">
395
+
396
+ <div class="method-heading">
397
+ <span class="method-name">continent_stat_uniq</span><span
398
+ class="method-args">(allcontinents,*platform)</span>
399
+ <span class="method-click-advice">click to toggle source</span>
400
+ </div>
401
+
402
+
403
+ <div class="method-description">
404
+
405
+ <p>It takes an array of continent codes as input, and produces a hash with the
406
+ continent codes as keys and the total number of ors from the country as
407
+ value</p>
408
+
409
+ <p>@example Get continents statistics</p>
410
+
411
+ <pre class="ruby"><span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">StatsObj</span>.<span class="ruby-identifier">continent_stat_uniq</span>([<span class="ruby-string">&quot;EU&quot;</span>,<span class="ruby-string">&quot;NA&quot;</span>,<span class="ruby-string">&quot;SA&quot;</span>]) =<span class="ruby-operator">&gt;</span> {<span class="ruby-string">&quot;EU&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">total</span>, <span class="ruby-operator">...</span>. <span class="ruby-string">&quot;SA&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">total</span> }
412
+ <span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">StatsObj</span>.<span class="ruby-identifier">continent_stat_uniq</span>([<span class="ruby-string">&quot;EU&quot;</span>,<span class="ruby-string">&quot;NA&quot;</span>,<span class="ruby-string">&quot;SA&quot;</span>], <span class="ruby-string">&quot;LINUX&quot;</span>)
413
+ <span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">StatsObj</span>.<span class="ruby-identifier">continent_stat_uniq</span>( <span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">StatsObj</span>.<span class="ruby-identifier">country_list</span> )
414
+ </pre>
415
+
416
+ <p>Note: Results of <a
417
+ href="StatsObj.html#method-i-continent_list">#continent_list</a> can be
418
+ used as argument for this <a
419
+ href="StatsObj.html#method-i-continent_stat_uniq">#continent_stat_uniq</a>.</p>
420
+
421
+
422
+
423
+ <div class="method-source-code" id="continent_stat_uniq-source">
424
+ <pre><span class="ruby-comment"># File lib/tstats.rb, line 209</span>
425
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">continent_stat_uniq</span>(<span class="ruby-identifier">allcontinents</span>,*<span class="ruby-identifier">platform</span>)
426
+ <span class="ruby-identifier">continent_count_hash</span>={}
427
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">allcontinents</span>.<span class="ruby-identifier">class</span><span class="ruby-operator">==</span><span class="ruby-constant">String</span>
428
+ <span class="ruby-identifier">continent_count_hash</span>[<span class="ruby-identifier">allcontinents</span>] = <span class="ruby-identifier">continent_count_uniq</span>(<span class="ruby-identifier">allcontinents</span>,*<span class="ruby-identifier">platform</span>)
429
+ <span class="ruby-keyword">else</span>
430
+ <span class="ruby-identifier">allcontinents</span>.<span class="ruby-identifier">each</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">each_continent</span><span class="ruby-operator">|</span>
431
+ <span class="ruby-identifier">continent_count_hash</span>[<span class="ruby-identifier">each_continent</span>] = <span class="ruby-identifier">continent_count_uniq</span>(<span class="ruby-identifier">each_continent</span>,*<span class="ruby-identifier">platform</span>)
432
+ }
433
+ <span class="ruby-keyword">end</span>
434
+ <span class="ruby-identifier">continent_count_hash</span>
435
+ <span class="ruby-keyword">end</span></pre>
436
+ </div><!-- continent_stat_uniq-source -->
437
+
438
+ </div>
439
+
440
+
441
+
442
+
443
+ </div><!-- continent_stat_uniq-method -->
444
+
445
+
446
+ <div id="method-i-country_count" class="method-detail ">
447
+
448
+ <div class="method-heading">
449
+ <span class="method-name">country_count</span><span
450
+ class="method-args">(code,*platform)</span>
451
+ <span class="method-click-advice">click to toggle source</span>
452
+ </div>
453
+
454
+
455
+ <div class="method-description">
456
+
457
+ <p>This returns the number of OR IP addresses from the country with the code
458
+ used as input (and optionally platform parameter).</p>
459
+
460
+ <p>@example Get number of OR IP addr from continents</p>
461
+
462
+ <pre>Tor::StatsObj.country_count(&quot;FR&quot;)
463
+ Tor::StatsObj.country_count(&quot;FR&quot;,&quot;UNIX&quot;)
464
+ Tor::StatsObj.country_count( [&quot;FR&quot;,&quot;DE&quot;] ,[ &quot;UNIX&quot;, &quot;LINUX&quot; ] )</pre>
465
+
466
+
467
+
468
+ <div class="method-source-code" id="country_count-source">
469
+ <pre><span class="ruby-comment"># File lib/tstats.rb, line 41</span>
470
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">country_count</span>(<span class="ruby-identifier">code</span>,*<span class="ruby-identifier">platform</span>)
471
+ <span class="ruby-identifier">rslt</span> = (<span class="ruby-identifier">platform</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">platform</span> <span class="ruby-operator">==</span> [<span class="ruby-string">&quot;ALL&quot;</span>] ) <span class="ruby-operator">?</span>
472
+ <span class="ruby-constant">Router</span>.<span class="ruby-identifier">where</span>(<span class="ruby-value">:country_code=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">code</span>) <span class="ruby-operator">:</span>
473
+ <span class="ruby-constant">Router</span>.<span class="ruby-identifier">where</span>(<span class="ruby-value">:country_code=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">code</span>,<span class="ruby-value">:platform=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">platform</span>)
474
+ <span class="ruby-identifier">rslt</span>.<span class="ruby-identifier">count</span>
475
+ <span class="ruby-keyword">end</span></pre>
476
+ </div><!-- country_count-source -->
477
+
478
+ </div>
479
+
480
+
481
+
482
+
483
+ </div><!-- country_count-method -->
484
+
485
+
486
+ <div id="method-i-country_count_uniq" class="method-detail ">
487
+
488
+ <div class="method-heading">
489
+ <span class="method-name">country_count_uniq</span><span
490
+ class="method-args">(countryfilter,*platform)</span>
491
+ <span class="method-click-advice">click to toggle source</span>
492
+ </div>
493
+
494
+
495
+ <div class="method-description">
496
+
497
+ <p>This returns the total number of uniq identities found in the database.</p>
498
+
499
+ <p>&lt;b&gt;Get total number of routers in countries&lt;b&gt;. <a
500
+ href="StatsObj.html#method-i-country_count_uniq">#country_count_uniq</a>)
501
+ <a
502
+ href="StatsObj.html#method-i-country_count_uniq">#country_count_uniq</a>("FR","WINDOWS")
503
+ <a
504
+ href="StatsObj.html#method-i-country_count_uniq">#country_count_uniq</a>,["UNIX",LINUX"]
505
+ )</p>
506
+
507
+
508
+
509
+ <div class="method-source-code" id="country_count_uniq-source">
510
+ <pre><span class="ruby-comment"># File lib/tstats.rb, line 55</span>
511
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">country_count_uniq</span>(<span class="ruby-identifier">countryfilter</span>,*<span class="ruby-identifier">platform</span>)
512
+ <span class="ruby-identifier">get_uniqid</span>(<span class="ruby-identifier">countryfilter</span>,*<span class="ruby-identifier">platform</span>).<span class="ruby-identifier">count</span>
513
+ <span class="ruby-keyword">end</span></pre>
514
+ </div><!-- country_count_uniq-source -->
515
+
516
+ </div>
517
+
518
+
519
+
520
+
521
+ </div><!-- country_count_uniq-method -->
522
+
523
+
524
+ <div id="method-i-country_getfingerprint" class="method-detail ">
525
+
526
+ <div class="method-heading">
527
+ <span class="method-name">country_getfingerprint</span><span
528
+ class="method-args">(country_filter,*platform)</span>
529
+ <span class="method-click-advice">click to toggle source</span>
530
+ </div>
531
+
532
+
533
+ <div class="method-description">
534
+
535
+ <p>This retuns an array of all OR fingerprints from the <a
536
+ href="Router.html">Tor::Router</a> using a filter of countries and optional
537
+ platform parameter.</p>
538
+
539
+ <p>@example Get all OR IP fingerprints from France</p>
540
+
541
+ <pre>Tor::StatsObj.country_getingerprint(&quot;FR&quot;)
542
+ Tor::StatsObj.country_getingerprint([&quot;FR&quot;,GB&quot;], &quot;WINDOWS&quot;)
543
+ Tor::StatsObj.country_getingerprint([&quot;FR&quot;,GB&quot;], [&quot;WINDOWS&quot;, &quot;LINUX&quot;] )</pre>
544
+
545
+
546
+
547
+ <div class="method-source-code" id="country_getfingerprint-source">
548
+ <pre><span class="ruby-comment"># File lib/tstats.rb, line 131</span>
549
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">country_getfingerprint</span>(<span class="ruby-identifier">country_filter</span>,*<span class="ruby-identifier">platform</span>)
550
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">platform</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">platform</span> <span class="ruby-operator">==</span> [<span class="ruby-string">&quot;ALL&quot;</span>]
551
+ <span class="ruby-identifier">onionr</span> = <span class="ruby-constant">Router</span>.<span class="ruby-identifier">where</span>(<span class="ruby-value">:country_code=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">country_filter</span>)
552
+ <span class="ruby-keyword">else</span>
553
+ <span class="ruby-identifier">onionr</span>=<span class="ruby-constant">Router</span>.<span class="ruby-identifier">where</span>(<span class="ruby-value">:country_code=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">country_filter</span>,<span class="ruby-value">:platform=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">platform</span> )
554
+ <span class="ruby-keyword">end</span>
555
+ <span class="ruby-identifier">onion_ipaddr</span> = <span class="ruby-identifier">onionr</span>.<span class="ruby-identifier">collect</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">each_country</span><span class="ruby-operator">|</span> <span class="ruby-identifier">each_country</span>.<span class="ruby-identifier">fingerprint</span>}
556
+ <span class="ruby-keyword">end</span></pre>
557
+ </div><!-- country_getfingerprint-source -->
558
+
559
+ </div>
560
+
561
+
562
+
563
+
564
+ </div><!-- country_getfingerprint-method -->
565
+
566
+
567
+ <div id="method-i-country_getip" class="method-detail ">
568
+
569
+ <div class="method-heading">
570
+ <span class="method-name">country_getip</span><span
571
+ class="method-args">(country_filter,*platform)</span>
572
+ <span class="method-click-advice">click to toggle source</span>
573
+ </div>
574
+
575
+
576
+ <div class="method-description">
577
+
578
+ <p>This retuns an array of all OR IP addresses from the <a
579
+ href="Router.html">Tor::Router</a> using a filter of countries and optional
580
+ platform parameter.</p>
581
+
582
+ <p>@example Get all OR IP addresses from France</p>
583
+
584
+ <pre>Tor::StatsObj.country_getip(&quot;FR&quot;)
585
+ Tor::StatsObj.country_getip([&quot;FR&quot;,GB&quot;], &quot;WINDOWS&quot;)
586
+ Tor::StatsObj.country_getip([&quot;FR&quot;,GB&quot;], [&quot;WINDOWS&quot;, &quot;LINUX&quot;] )</pre>
587
+
588
+
589
+
590
+ <div class="method-source-code" id="country_getip-source">
591
+ <pre><span class="ruby-comment"># File lib/tstats.rb, line 115</span>
592
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">country_getip</span>(<span class="ruby-identifier">country_filter</span>,*<span class="ruby-identifier">platform</span>)
593
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">platform</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">platform</span> <span class="ruby-operator">==</span> [<span class="ruby-string">&quot;ALL&quot;</span>]
594
+ <span class="ruby-identifier">onionr</span> = <span class="ruby-constant">Router</span>.<span class="ruby-identifier">where</span>(<span class="ruby-value">:country_code=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">country_filter</span>)
595
+ <span class="ruby-keyword">else</span>
596
+ <span class="ruby-identifier">onionr</span>=<span class="ruby-constant">Router</span>.<span class="ruby-identifier">where</span>(<span class="ruby-value">:country_code=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">country_filter</span>,<span class="ruby-value">:platform=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">platform</span> )
597
+ <span class="ruby-keyword">end</span>
598
+ <span class="ruby-identifier">onion_ipaddr</span>=<span class="ruby-identifier">onionr</span>.<span class="ruby-identifier">collect</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">each_country</span><span class="ruby-operator">|</span> <span class="ruby-identifier">each_country</span>.<span class="ruby-identifier">ipaddr</span>}
599
+ <span class="ruby-keyword">end</span></pre>
600
+ </div><!-- country_getip-source -->
601
+
602
+ </div>
603
+
604
+
605
+
606
+
607
+ </div><!-- country_getip-method -->
608
+
609
+
610
+ <div id="method-i-country_list" class="method-detail ">
611
+
612
+ <div class="method-heading">
613
+ <span class="method-name">country_list</span><span
614
+ class="method-args">(*platform)</span>
615
+ <span class="method-click-advice">click to toggle source</span>
616
+ </div>
617
+
618
+
619
+ <div class="method-description">
620
+
621
+ <p>This returns a list of all countries that have contributed to the OR IP
622
+ addresses in <a href="Router.html">Tor::Router</a> It can return only the
623
+ those that have contributed to a particular platform</p>
624
+
625
+ <p>@example Get Countries the that use Unix</p>
626
+
627
+ <pre>Tor::StatsObj.country_list
628
+ Tor::StatsObj.country_list(&quot;UNIX&quot;)
629
+ Tor::StatsObj.country_list( [&quot;UNIX&quot;, &quot;LINUX&quot;] )</pre>
630
+
631
+
632
+
633
+ <div class="method-source-code" id="country_list-source">
634
+ <pre><span class="ruby-comment"># File lib/tstats.rb, line 16</span>
635
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">country_list</span>(*<span class="ruby-identifier">platform</span>)
636
+ <span class="ruby-identifier">tmpresult</span> = (<span class="ruby-identifier">platform</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">platform</span> <span class="ruby-operator">==</span> [<span class="ruby-string">&quot;ALL&quot;</span>]) <span class="ruby-operator">?</span> <span class="ruby-constant">Router</span>.<span class="ruby-identifier">all</span> <span class="ruby-operator">:</span> <span class="ruby-constant">Router</span>.<span class="ruby-identifier">where</span>(<span class="ruby-value">:platform=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">platform</span>)
637
+ <span class="ruby-identifier">tmpresult</span>.<span class="ruby-identifier">group_by</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">country_code</span>}.<span class="ruby-identifier">keys</span>
638
+ <span class="ruby-keyword">end</span></pre>
639
+ </div><!-- country_list-source -->
640
+
641
+ </div>
642
+
643
+
644
+
645
+
646
+ </div><!-- country_list-method -->
647
+
648
+
649
+ <div id="method-i-country_stat" class="method-detail ">
650
+
651
+ <div class="method-heading">
652
+ <span class="method-name">country_stat</span><span
653
+ class="method-args">(countrycodes,*platform)</span>
654
+ <span class="method-click-advice">click to toggle source</span>
655
+ </div>
656
+
657
+
658
+ <div class="method-description">
659
+
660
+ <p>It takes an array of country codes as input, and produces a hash with the
661
+ country codes as keys and the total number of ors from the country as
662
+ value. An optional platform can also be set.</p>
663
+
664
+ <p>@example Get country statistics</p>
665
+
666
+ <pre class="ruby"><span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">StatsObj</span>.<span class="ruby-identifier">country_stat</span>([<span class="ruby-string">&quot;EU&quot;</span>,<span class="ruby-string">&quot;NA&quot;</span>,<span class="ruby-string">&quot;SA&quot;</span>]) =<span class="ruby-operator">&gt;</span> {<span class="ruby-string">&quot;EU&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">country</span>,<span class="ruby-identifier">total</span>, <span class="ruby-operator">...</span>. <span class="ruby-string">&quot;SA&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">country</span>,<span class="ruby-identifier">total</span> }
667
+ <span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">StatsObj</span>.<span class="ruby-identifier">country_stat</span>([<span class="ruby-string">&quot;EU&quot;</span>,<span class="ruby-string">&quot;NA&quot;</span>,<span class="ruby-string">&quot;SA&quot;</span>], <span class="ruby-string">&quot;LINUX&quot;</span>)
668
+ <span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">StatsObj</span>.<span class="ruby-identifier">country_stat</span>( <span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">StatsObj</span>.<span class="ruby-identifier">country_list</span> )
669
+ <span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">StatsObj</span>.<span class="ruby-identifier">country_stat</span>( <span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">StatsObj</span>.<span class="ruby-identifier">country_list</span>(<span class="ruby-identifier">platform</span>) )
670
+ </pre>
671
+
672
+ <p>Note: Results of <a
673
+ href="StatsObj.html#method-i-country_list">#country_list</a> can be used as
674
+ argument for this <a
675
+ href="StatsObj.html#method-i-country_stat">#country_stat</a>.</p>
676
+
677
+
678
+
679
+ <div class="method-source-code" id="country_stat-source">
680
+ <pre><span class="ruby-comment"># File lib/tstats.rb, line 98</span>
681
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">country_stat</span>(<span class="ruby-identifier">countrycodes</span>,*<span class="ruby-identifier">platform</span>)
682
+ <span class="ruby-identifier">country_count_hash</span>={}
683
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">countrycodes</span>.<span class="ruby-identifier">class</span><span class="ruby-operator">==</span><span class="ruby-constant">String</span>
684
+ <span class="ruby-identifier">country_count_hash</span>[<span class="ruby-identifier">countrycodes</span>] = <span class="ruby-identifier">country_count</span>(<span class="ruby-identifier">countrycodes</span>,*<span class="ruby-identifier">platform</span>)
685
+ <span class="ruby-keyword">else</span>
686
+ <span class="ruby-identifier">countrycodes</span>.<span class="ruby-identifier">each</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">each_country</span><span class="ruby-operator">|</span> <span class="ruby-identifier">country_count_hash</span>[<span class="ruby-identifier">each_country</span>] = <span class="ruby-identifier">country_count</span>(<span class="ruby-identifier">each_country</span>,*<span class="ruby-identifier">platform</span>)}
687
+ <span class="ruby-keyword">end</span>
688
+ <span class="ruby-identifier">country_count_hash</span>
689
+ <span class="ruby-keyword">end</span></pre>
690
+ </div><!-- country_stat-source -->
691
+
692
+ </div>
693
+
694
+
695
+
696
+
697
+ </div><!-- country_stat-method -->
698
+
699
+
700
+ <div id="method-i-country_stat_uniq" class="method-detail ">
701
+
702
+ <div class="method-heading">
703
+ <span class="method-name">country_stat_uniq</span><span
704
+ class="method-args">(countrycodes,*platform)</span>
705
+ <span class="method-click-advice">click to toggle source</span>
706
+ </div>
707
+
708
+
709
+ <div class="method-description">
710
+
711
+ <p>It takes an array of country codes as input, and produces a hash with the
712
+ country codes as keys and the total number of unique ors from the country
713
+ as value. An optional platform can also be set.</p>
714
+
715
+ <p>@example Get country statistics</p>
716
+
717
+ <pre class="ruby"><span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">StatsObj</span>.<span class="ruby-identifier">country_stat_uniq</span>([<span class="ruby-string">&quot;FR&quot;</span>,<span class="ruby-string">&quot;GB&quot;</span>,<span class="ruby-string">&quot;US&quot;</span>]) =<span class="ruby-operator">&gt;</span> {<span class="ruby-string">&quot;FR&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">total</span>, <span class="ruby-operator">...</span>. <span class="ruby-string">&quot;US&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">total</span> }
718
+ <span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">StatsObj</span>.<span class="ruby-identifier">country_stat_uniq</span>([<span class="ruby-constant">DE</span><span class="ruby-string">&quot;,&quot;</span><span class="ruby-constant">FR</span><span class="ruby-string">&quot;], &quot;</span><span class="ruby-constant">LINUX</span><span class="ruby-string">&quot;)
719
+ Tor::StatsObj.country_stat_uniq( Tor::StatsObj.country_list )
720
+ Tor::StatsObj.country_stat_uniq( Tor::StatsObj.country_list(platform) )
721
+ </span></pre>
722
+
723
+ <p>Note: Results of <a
724
+ href="StatsObj.html#method-i-country_list">#country_list</a> can be used as
725
+ argument for this <a
726
+ href="StatsObj.html#method-i-country_stat_uniq">#country_stat_uniq</a>.</p>
727
+
728
+
729
+
730
+ <div class="method-source-code" id="country_stat_uniq-source">
731
+ <pre><span class="ruby-comment"># File lib/tstats.rb, line 167</span>
732
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">country_stat_uniq</span>(<span class="ruby-identifier">countrycodes</span>,*<span class="ruby-identifier">platform</span>)
733
+ <span class="ruby-comment"># get_uniqid can be used for this, but this that will involve more calls to Tor::Router than necessary</span>
734
+ <span class="ruby-identifier">country_count_hash</span>={}
735
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">countrycodes</span>.<span class="ruby-identifier">class</span><span class="ruby-operator">==</span><span class="ruby-constant">String</span>
736
+ <span class="ruby-identifier">country_count_hash</span>[<span class="ruby-identifier">countrycodes</span>] = <span class="ruby-identifier">country_count_uniq</span>(<span class="ruby-identifier">countrycodes</span>,*<span class="ruby-identifier">platform</span>)
737
+ <span class="ruby-keyword">else</span>
738
+ <span class="ruby-identifier">countrycodes</span>.<span class="ruby-identifier">each</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">each_country</span><span class="ruby-operator">|</span>
739
+ <span class="ruby-identifier">country_count_hash</span>[<span class="ruby-identifier">each_country</span>] = <span class="ruby-identifier">country_count_uniq</span>(<span class="ruby-identifier">each_country</span>,*<span class="ruby-identifier">platform</span>) }
740
+ <span class="ruby-keyword">end</span>
741
+ <span class="ruby-identifier">country_count_hash</span>
742
+ <span class="ruby-keyword">end</span></pre>
743
+ </div><!-- country_stat_uniq-source -->
744
+
745
+ </div>
746
+
747
+
748
+
749
+
750
+ </div><!-- country_stat_uniq-method -->
751
+
752
+
753
+ <div id="method-i-genkml" class="method-detail ">
754
+
755
+ <div class="method-heading">
756
+ <span class="method-name">genkml</span><span
757
+ class="method-args">(mapname,*platform)</span>
758
+ <span class="method-click-advice">click to toggle source</span>
759
+ </div>
760
+
761
+
762
+ <div class="method-description">
763
+
764
+ <p>This method generates a KML using the locations in <a
765
+ href="Router.html">Tor::Router</a> database. It takes a name for the KML
766
+ document as input, and an optional platform parameter.</p>
767
+
768
+ <p>@example Generate KML file</p>
769
+
770
+ <pre>Tor::StatsObj.genkml(&quot;KML doc name&quot;)
771
+ Tor::StatsObj.genkml(&quot;KML platform name&quot;, [&quot;WINDOWS&quot;,&quot;UNIX&quot;,&quot;LINUX&quot;, &quot;OTHER&quot;] )
772
+ Tor::StatsObj.genkml(&quot;KML platform name&quot;, &quot;LINUX&quot; )</pre>
773
+
774
+
775
+
776
+ <div class="method-source-code" id="genkml-source">
777
+ <pre><span class="ruby-comment"># File lib/tstats.rb, line 310</span>
778
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">genkml</span>(<span class="ruby-identifier">mapname</span>,*<span class="ruby-identifier">platform</span>)
779
+ <span class="ruby-identifier">tour_hash</span>= (<span class="ruby-keyword">defined?</span> <span class="ruby-constant">WORLDTOUR</span>) <span class="ruby-operator">?</span> <span class="ruby-constant">WORLDTOUR</span> <span class="ruby-operator">:</span> <span class="ruby-constant">Constants</span><span class="ruby-operator">::</span><span class="ruby-constant">WORLDTOUR</span>
780
+ <span class="ruby-identifier">attack_tour</span> = (<span class="ruby-keyword">defined?</span> <span class="ruby-constant">ATTACK_TOUR</span>) <span class="ruby-operator">?</span> <span class="ruby-constant">ATTACK_TOUR</span><span class="ruby-operator">:</span> <span class="ruby-constant">Constants</span><span class="ruby-operator">::</span><span class="ruby-constant">ATTACK_TOUR</span>
781
+
782
+ <span class="ruby-identifier">torcountry</span>= <span class="ruby-identifier">topcountries_uniq</span>(<span class="ruby-value">0</span>,*<span class="ruby-identifier">platform</span>) <span class="ruby-comment"># collect{|country,count| country} </span>
783
+ <span class="ruby-identifier">xml</span> = <span class="ruby-constant">Builder</span><span class="ruby-operator">::</span><span class="ruby-constant">XmlMarkup</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">:indent=</span><span class="ruby-operator">&gt;</span><span class="ruby-value">2</span>)
784
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">instruct!</span> <span class="ruby-value">:xml</span>, <span class="ruby-value">:version=</span><span class="ruby-operator">&gt;</span><span class="ruby-string">&quot;1.0&quot;</span>, <span class="ruby-value">:encoding=</span><span class="ruby-operator">&gt;</span><span class="ruby-string">&quot;UTF-8&quot;</span>
785
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">kml</span>(<span class="ruby-string">&quot;xmlns&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;http://www.opengis.net/kml/2.2&quot;</span>,
786
+ <span class="ruby-string">&quot;xmlns:gx&quot;</span>=<span class="ruby-operator">&gt;</span><span class="ruby-string">&quot;http://www.google.com/kml/ext/2.2&quot;</span>) <span class="ruby-keyword">do</span>
787
+ <span class="ruby-identifier">y</span>=<span class="ruby-value">1</span>
788
+
789
+
790
+ <span class="ruby-identifier">xml</span>.<span class="ruby-constant">Document</span> <span class="ruby-keyword">do</span>
791
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">name</span> <span class="ruby-identifier">mapname</span>
792
+
793
+ <span class="ruby-comment"># define styles to use for placemarks and tour</span>
794
+ <span class="ruby-identifier">xml</span>.<span class="ruby-constant">Style</span>(<span class="ruby-string">&quot;id&quot;</span>=<span class="ruby-operator">&gt;</span><span class="ruby-string">&quot;redplaces&quot;</span>) <span class="ruby-keyword">do</span>
795
+ <span class="ruby-identifier">xml</span>.<span class="ruby-constant">IconStyle</span> <span class="ruby-keyword">do</span>
796
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">color</span> <span class="ruby-string">&quot;ff0000ff&quot;</span>
797
+ <span class="ruby-keyword">end</span>
798
+ <span class="ruby-keyword">end</span>
799
+ <span class="ruby-identifier">xml</span>.<span class="ruby-constant">Style</span>(<span class="ruby-string">&quot;id&quot;</span>=<span class="ruby-operator">&gt;</span><span class="ruby-string">&quot;greenplaces&quot;</span>) <span class="ruby-keyword">do</span>
800
+ <span class="ruby-identifier">xml</span>.<span class="ruby-constant">IconStyle</span> <span class="ruby-keyword">do</span>
801
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">color</span> <span class="ruby-string">&quot;ff00ff00&quot;</span>
802
+ <span class="ruby-keyword">end</span>
803
+ <span class="ruby-keyword">end</span>
804
+ <span class="ruby-identifier">xml</span>.<span class="ruby-constant">Style</span>(<span class="ruby-string">&quot;id&quot;</span>=<span class="ruby-operator">&gt;</span><span class="ruby-string">&quot;blackplaces&quot;</span>) <span class="ruby-keyword">do</span>
805
+ <span class="ruby-identifier">xml</span>.<span class="ruby-constant">IconStyle</span> <span class="ruby-keyword">do</span>
806
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">color</span> <span class="ruby-string">&quot;ff000000&quot;</span>
807
+ <span class="ruby-keyword">end</span>
808
+ <span class="ruby-keyword">end</span>
809
+ <span class="ruby-identifier">xml</span>.<span class="ruby-constant">Style</span>(<span class="ruby-string">&quot;id&quot;</span>=<span class="ruby-operator">&gt;</span><span class="ruby-string">&quot;blueplaces&quot;</span>) <span class="ruby-keyword">do</span>
810
+ <span class="ruby-identifier">xml</span>.<span class="ruby-constant">IconStyle</span> <span class="ruby-keyword">do</span>
811
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">color</span> <span class="ruby-string">&quot;0000ff00&quot;</span>
812
+ <span class="ruby-keyword">end</span>
813
+ <span class="ruby-keyword">end</span>
814
+
815
+ <span class="ruby-identifier">xml</span>.<span class="ruby-constant">Folder</span>(<span class="ruby-string">&quot;id&quot;</span>=<span class="ruby-operator">&gt;</span><span class="ruby-string">&quot;torbridges&quot;</span>) <span class="ruby-keyword">do</span>
816
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">name</span> <span class="ruby-node">&quot;Tor Bridges - #{Bridge.count}&quot;</span>
817
+ <span class="ruby-identifier">allbridges</span> = <span class="ruby-constant">Bridge</span>.<span class="ruby-identifier">all</span>
818
+ <span class="ruby-identifier">allbridges</span>.<span class="ruby-identifier">each</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">eachbridge</span><span class="ruby-operator">|</span>
819
+ <span class="ruby-identifier">brindex</span> = <span class="ruby-value">1</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">allbridges</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">eachbridge</span>)
820
+ <span class="ruby-identifier">placeid</span> = <span class="ruby-node">&quot;bridge#{brindex }&quot;</span>
821
+ <span class="ruby-identifier">xml</span>.<span class="ruby-constant">Placemark</span>(<span class="ruby-string">&quot;id&quot;</span>=<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">placeid</span>) <span class="ruby-keyword">do</span>
822
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">name</span> <span class="ruby-node">&quot;BR#{brindex.to_s}&quot;</span>
823
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">description</span> <span class="ruby-node">&quot;#{eachbridge.ipaddr}:#{eachbridge.port}&quot;</span>
824
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">styleUrl</span> <span class="ruby-node">&quot;#blueplaces&quot;</span>
825
+ <span class="ruby-identifier">xml</span>.<span class="ruby-constant">Point</span> <span class="ruby-keyword">do</span>
826
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">extrude</span> <span class="ruby-value">1</span>
827
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">coordinates</span> <span class="ruby-node">&quot;#{eachbridge.lng},#{eachbridge.lat}&quot;</span>
828
+ <span class="ruby-keyword">end</span>
829
+ <span class="ruby-keyword">end</span>
830
+ }
831
+ <span class="ruby-keyword">end</span>
832
+
833
+ <span class="ruby-comment"># Google earth tour</span>
834
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">gx</span> <span class="ruby-value">:Tour</span> <span class="ruby-keyword">do</span>
835
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">name</span> <span class="ruby-string">&quot;Tor World&quot;</span>
836
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">gx</span> <span class="ruby-value">:Playlist</span> <span class="ruby-keyword">do</span>
837
+ <span class="ruby-identifier">tour_hash</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">each_centre</span><span class="ruby-operator">|</span>
838
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">gx</span> <span class="ruby-value">:FlyTo</span> <span class="ruby-keyword">do</span>
839
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">gx</span> <span class="ruby-value">:duration</span>,<span class="ruby-value">1.0</span>
840
+ <span class="ruby-identifier">xml</span>.<span class="ruby-constant">LookAt</span> <span class="ruby-keyword">do</span>
841
+ <span class="ruby-identifier">country_lat</span>,<span class="ruby-identifier">country_lng</span>= <span class="ruby-identifier">get_latlng</span>(<span class="ruby-identifier">each_centre</span>)
842
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">longitude</span> <span class="ruby-identifier">country_lng</span>
843
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">latitude</span> <span class="ruby-identifier">country_lat</span>
844
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">range</span> <span class="ruby-value">4900000</span>
845
+ <span class="ruby-keyword">end</span> <span class="ruby-comment">#end LookAt</span>
846
+ <span class="ruby-keyword">end</span> <span class="ruby-comment"># end FlyTo</span>
847
+
848
+
849
+ <span class="ruby-identifier">tour_hash</span>[<span class="ruby-identifier">each_centre</span>].<span class="ruby-identifier">each</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">eachzone</span><span class="ruby-operator">|</span>
850
+ <span class="ruby-comment"># toggle on</span>
851
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">gx</span> <span class="ruby-value">:AnimatedUpdate</span> <span class="ruby-keyword">do</span>
852
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">gx</span> <span class="ruby-value">:duration</span>,<span class="ruby-value">0.0</span>
853
+ <span class="ruby-identifier">xml</span>.<span class="ruby-constant">Update</span> <span class="ruby-keyword">do</span>
854
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">targetHref</span>
855
+ <span class="ruby-identifier">xml</span>.<span class="ruby-constant">Change</span> <span class="ruby-keyword">do</span>
856
+ <span class="ruby-identifier">xml</span>.<span class="ruby-constant">Placemark</span>(<span class="ruby-string">&quot;targetId&quot;</span>=<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">eachzone</span>) <span class="ruby-keyword">do</span>
857
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">gx</span> <span class="ruby-value">:balloonVisibility</span>,<span class="ruby-value">1</span>
858
+ <span class="ruby-keyword">end</span> <span class="ruby-comment"># end Placemark</span>
859
+ <span class="ruby-keyword">end</span> <span class="ruby-comment"># end Change</span>
860
+ <span class="ruby-keyword">end</span> <span class="ruby-comment"># end Update</span>
861
+ <span class="ruby-keyword">end</span> <span class="ruby-comment">#end AnimatedUpdate</span>
862
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">gx</span> <span class="ruby-value">:Wait</span> <span class="ruby-keyword">do</span>
863
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">gx</span> <span class="ruby-value">:duration</span>,<span class="ruby-value">2.0</span>
864
+ <span class="ruby-keyword">end</span>
865
+
866
+ <span class="ruby-comment"># toggle off</span>
867
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">gx</span> <span class="ruby-value">:AnimatedUpdate</span> <span class="ruby-keyword">do</span>
868
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">gx</span> <span class="ruby-value">:duration</span>,<span class="ruby-value">0.0</span>
869
+ <span class="ruby-identifier">xml</span>.<span class="ruby-constant">Update</span> <span class="ruby-keyword">do</span>
870
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">targetHref</span>
871
+ <span class="ruby-identifier">xml</span>.<span class="ruby-constant">Change</span> <span class="ruby-keyword">do</span>
872
+ <span class="ruby-identifier">xml</span>.<span class="ruby-constant">Placemark</span>(<span class="ruby-string">&quot;id&quot;</span>=<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">eachzone</span>) <span class="ruby-keyword">do</span>
873
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">gx</span> <span class="ruby-value">:balloonVisibility</span>,<span class="ruby-value">0</span>
874
+ <span class="ruby-keyword">end</span> <span class="ruby-comment"># end placemark</span>
875
+ <span class="ruby-keyword">end</span> <span class="ruby-comment"># end Change</span>
876
+ <span class="ruby-keyword">end</span> <span class="ruby-comment"># end Update</span>
877
+ <span class="ruby-keyword">end</span> <span class="ruby-comment"># end AnimatedUpdate</span>
878
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">gx</span> <span class="ruby-value">:Wait</span> <span class="ruby-keyword">do</span>
879
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">gx</span> <span class="ruby-value">:duration</span>,<span class="ruby-value">2.0</span>
880
+ <span class="ruby-keyword">end</span>
881
+ } <span class="ruby-comment"># eachzone</span>
882
+ } <span class="ruby-comment">#each_centre</span>
883
+ <span class="ruby-keyword">end</span> <span class="ruby-comment"># end of gx:Playlist</span>
884
+ <span class="ruby-keyword">end</span> <span class="ruby-comment"># end of gx:Tour</span>
885
+
886
+
887
+ <span class="ruby-comment"># Google earth attack tour</span>
888
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">gx</span> <span class="ruby-value">:Tour</span> <span class="ruby-keyword">do</span>
889
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">name</span> <span class="ruby-string">&quot;Tor - Attack&quot;</span>
890
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">gx</span> <span class="ruby-value">:Playlist</span> <span class="ruby-keyword">do</span>
891
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">gx</span> <span class="ruby-value">:FlyTo</span> <span class="ruby-keyword">do</span>
892
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">gx</span> <span class="ruby-value">:duration</span>,<span class="ruby-value">1.0</span>
893
+ <span class="ruby-identifier">xml</span>.<span class="ruby-constant">LookAt</span> <span class="ruby-keyword">do</span>
894
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">longitude</span> <span class="ruby-identifier">attack_tour</span>[<span class="ruby-value">:lng</span>]
895
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">latitude</span> <span class="ruby-identifier">attack_tour</span>[<span class="ruby-value">:lat</span>]
896
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">range</span> <span class="ruby-value">2000000</span>
897
+ <span class="ruby-keyword">end</span> <span class="ruby-comment">#end LookAt</span>
898
+ <span class="ruby-keyword">end</span> <span class="ruby-comment"># end FlyTo</span>
899
+
900
+
901
+ <span class="ruby-identifier">attack_tour</span>[<span class="ruby-string">&quot;red&quot;</span>].<span class="ruby-identifier">each</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">eachzone</span><span class="ruby-operator">|</span>
902
+ <span class="ruby-comment"># toggle on</span>
903
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">gx</span> <span class="ruby-value">:AnimatedUpdate</span> <span class="ruby-keyword">do</span>
904
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">gx</span> <span class="ruby-value">:duration</span>,<span class="ruby-value">0.0</span>
905
+ <span class="ruby-identifier">xml</span>.<span class="ruby-constant">Update</span> <span class="ruby-keyword">do</span>
906
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">targetHref</span>
907
+ <span class="ruby-identifier">xml</span>.<span class="ruby-constant">Change</span> <span class="ruby-keyword">do</span>
908
+ <span class="ruby-identifier">xml</span>.<span class="ruby-constant">Placemark</span>(<span class="ruby-string">&quot;targetId&quot;</span>=<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">eachzone</span>) <span class="ruby-keyword">do</span>
909
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">styleUrl</span> <span class="ruby-node">&quot;#redplaces&quot;</span>
910
+ <span class="ruby-keyword">end</span> <span class="ruby-comment"># end Placemark</span>
911
+ <span class="ruby-keyword">end</span> <span class="ruby-comment"># end Change</span>
912
+ <span class="ruby-keyword">end</span> <span class="ruby-comment"># end Update</span>
913
+ <span class="ruby-keyword">end</span> <span class="ruby-comment">#end AnimatedUpdate</span>
914
+ } <span class="ruby-comment"># eachzone</span>
915
+
916
+ <span class="ruby-identifier">attack_tour</span>[<span class="ruby-string">&quot;black&quot;</span>].<span class="ruby-identifier">each</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">eachzone</span><span class="ruby-operator">|</span>
917
+ <span class="ruby-comment"># toggle on</span>
918
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">gx</span> <span class="ruby-value">:AnimatedUpdate</span> <span class="ruby-keyword">do</span>
919
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">gx</span> <span class="ruby-value">:duration</span>,<span class="ruby-value">2.0</span>
920
+ <span class="ruby-identifier">xml</span>.<span class="ruby-constant">Update</span> <span class="ruby-keyword">do</span>
921
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">targetHref</span>
922
+ <span class="ruby-identifier">xml</span>.<span class="ruby-constant">Change</span> <span class="ruby-keyword">do</span>
923
+ <span class="ruby-identifier">xml</span>.<span class="ruby-constant">Placemark</span>(<span class="ruby-string">&quot;targetId&quot;</span>=<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">eachzone</span>) <span class="ruby-keyword">do</span>
924
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">styleUrl</span> <span class="ruby-node">&quot;#blackplaces&quot;</span>
925
+ <span class="ruby-keyword">end</span> <span class="ruby-comment"># end Placemark</span>
926
+ <span class="ruby-keyword">end</span> <span class="ruby-comment"># end Change</span>
927
+ <span class="ruby-keyword">end</span> <span class="ruby-comment"># end Update</span>
928
+ <span class="ruby-keyword">end</span> <span class="ruby-comment">#end AnimatedUpdate</span>
929
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">gx</span> <span class="ruby-value">:Wait</span> <span class="ruby-keyword">do</span>
930
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">gx</span> <span class="ruby-value">:duration</span>,<span class="ruby-value">2.0</span>
931
+ <span class="ruby-keyword">end</span>
932
+ } <span class="ruby-comment"># eachzone</span>
933
+
934
+ <span class="ruby-keyword">end</span> <span class="ruby-comment"># end of gx:Playlist</span>
935
+ <span class="ruby-keyword">end</span> <span class="ruby-comment"># end of gx:Tour</span>
936
+
937
+ <span class="ruby-identifier">torcountry</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">country_code</span>,<span class="ruby-identifier">countrytotal</span><span class="ruby-operator">|</span>
938
+ <span class="ruby-identifier">countryname</span> = <span class="ruby-identifier">get_countryname</span>(<span class="ruby-identifier">country_code</span>)
939
+ <span class="ruby-identifier">xml</span>.<span class="ruby-constant">Folder</span>(<span class="ruby-string">&quot;id&quot;</span>=<span class="ruby-operator">&gt;</span><span class="ruby-identifier">country_code</span>) <span class="ruby-keyword">do</span>
940
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">name</span> <span class="ruby-node">&quot;#{countryname}-#{countrytotal}&quot;</span>
941
+ <span class="ruby-identifier">xml</span>.<span class="ruby-constant">LookAt</span> <span class="ruby-keyword">do</span>
942
+ <span class="ruby-identifier">country_lat</span>,<span class="ruby-identifier">country_lng</span> = <span class="ruby-identifier">get_latlng</span>(<span class="ruby-identifier">country_code</span>)
943
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">longitude</span> <span class="ruby-identifier">country_lng</span>
944
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">latitude</span> <span class="ruby-identifier">country_lat</span>
945
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">range</span> <span class="ruby-value">4500000</span>
946
+ <span class="ruby-keyword">end</span>
947
+ <span class="ruby-identifier">idarray</span> = <span class="ruby-identifier">get_uniqid</span>(<span class="ruby-identifier">country_code</span>,*<span class="ruby-identifier">platform</span>)
948
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">platform</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">platform</span><span class="ruby-operator">==</span>[<span class="ruby-string">&quot;ALL&quot;</span>] <span class="ruby-keyword">or</span> <span class="ruby-identifier">platform</span><span class="ruby-operator">==</span>[<span class="ruby-string">&quot;All&quot;</span>]
949
+ <span class="ruby-identifier">torlocations</span> = <span class="ruby-constant">Router</span>.<span class="ruby-identifier">where</span>(<span class="ruby-value">:id=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">idarray</span>,<span class="ruby-value">:country_code=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">country_code</span>)
950
+ <span class="ruby-keyword">else</span>
951
+ <span class="ruby-identifier">torlocations</span> = <span class="ruby-constant">Router</span>.<span class="ruby-identifier">where</span>(<span class="ruby-value">:id=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">idarray</span>,<span class="ruby-value">:country_code=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">country_code</span>,<span class="ruby-value">:platform=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">platform</span>)
952
+ <span class="ruby-keyword">end</span>
953
+ <span class="ruby-identifier">torplaces_sorted</span> = <span class="ruby-identifier">torlocations</span>.<span class="ruby-identifier">group_by</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> [ <span class="ruby-identifier">c</span>.<span class="ruby-identifier">lat</span>, <span class="ruby-identifier">c</span>.<span class="ruby-identifier">lng</span>, <span class="ruby-identifier">c</span>.<span class="ruby-identifier">country</span>, <span class="ruby-identifier">c</span>.<span class="ruby-identifier">city</span> ] }.<span class="ruby-identifier">sort_by</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">a</span>,<span class="ruby-identifier">b</span><span class="ruby-operator">|</span> <span class="ruby-identifier">b</span>.<span class="ruby-identifier">count</span>}.<span class="ruby-identifier">reverse</span>
954
+ <span class="ruby-identifier">torplaces_sorted</span>.<span class="ruby-identifier">each</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">lat_lng_country_city</span><span class="ruby-operator">|</span>
955
+ <span class="ruby-comment"># Group by fingerprint here and get the size of the hash, and get the number of elements in the hash instead of get_uniqid</span>
956
+ <span class="ruby-comment"># but what if user is mobile? different isps, latitude-longitude, or lives the city or country</span>
957
+ <span class="ruby-identifier">lat</span>, <span class="ruby-identifier">lng</span>, <span class="ruby-identifier">country</span>, <span class="ruby-identifier">city</span> = <span class="ruby-identifier">lat_lng_country_city</span>[<span class="ruby-value">0</span>]
958
+ <span class="ruby-identifier">pointtotal</span> = <span class="ruby-identifier">lat_lng_country_city</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">count</span>
959
+ <span class="ruby-identifier">placeid</span> = <span class="ruby-node">&quot;#{country_code}#{ 1 + torplaces_sorted.index(lat_lng_country_city)}&quot;</span>
960
+ <span class="ruby-identifier">xml</span>.<span class="ruby-constant">Placemark</span>(<span class="ruby-string">&quot;id&quot;</span>=<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">placeid</span>) <span class="ruby-keyword">do</span>
961
+ <span class="ruby-identifier">strcount</span> = (<span class="ruby-identifier">pointtotal</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>) <span class="ruby-operator">?</span> <span class="ruby-string">'OR'</span> <span class="ruby-operator">:</span> <span class="ruby-string">'ORs'</span>
962
+ <span class="ruby-comment">#xml.name &quot;#{y}&quot;</span>
963
+ <span class="ruby-identifier">y</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
964
+ <span class="ruby-identifier">kmlcity</span>= (<span class="ruby-identifier">city</span>.<span class="ruby-identifier">empty?</span>) <span class="ruby-operator">?</span> <span class="ruby-node">&quot;#{country}&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-node">&quot;#{city}&quot;</span>
965
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">description</span> <span class="ruby-node">&quot;#{pointtotal} #{strcount} in #{kmlcity} of #{countrytotal}(country total)&quot;</span>
966
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">styleUrl</span> <span class="ruby-node">&quot;#greenplaces&quot;</span>
967
+ <span class="ruby-identifier">xml</span>.<span class="ruby-constant">Point</span> <span class="ruby-keyword">do</span>
968
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">extrude</span> <span class="ruby-value">1</span>
969
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">coordinates</span> <span class="ruby-node">&quot;#{lng},#{lat}&quot;</span>
970
+ <span class="ruby-keyword">end</span>
971
+ <span class="ruby-keyword">end</span>
972
+ }
973
+ <span class="ruby-keyword">end</span>
974
+ }
975
+ <span class="ruby-keyword">end</span>
976
+ <span class="ruby-keyword">end</span>
977
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">target!</span> <span class="ruby-comment">#Return the xml file</span>
978
+ <span class="ruby-keyword">end</span></pre>
979
+ </div><!-- genkml-source -->
980
+
981
+ </div>
982
+
983
+
984
+
985
+
986
+ </div><!-- genkml-method -->
987
+
988
+
989
+ <div id="method-i-get_countryname" class="method-detail ">
990
+
991
+ <div class="method-heading">
992
+ <span class="method-name">get_countryname</span><span
993
+ class="method-args">(ccode)</span>
994
+ <span class="method-click-advice">click to toggle source</span>
995
+ </div>
996
+
997
+
998
+ <div class="method-description">
999
+
1000
+ <p>This returns the country name from the country code.</p>
1001
+
1002
+ <p>@example Get country name from country code</p>
1003
+
1004
+ <pre>Tor::StatsObj.get_countryname(&quot;FR&quot;)</pre>
1005
+
1006
+
1007
+
1008
+ <div class="method-source-code" id="get_countryname-source">
1009
+ <pre><span class="ruby-comment"># File lib/tstats.rb, line 254</span>
1010
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">get_countryname</span>(<span class="ruby-identifier">ccode</span>)
1011
+ <span class="ruby-identifier">x</span>=<span class="ruby-constant">Router</span>.<span class="ruby-identifier">where</span>(<span class="ruby-value">:country_code=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">ccode</span>).<span class="ruby-identifier">first</span>
1012
+ (<span class="ruby-identifier">x</span>.<span class="ruby-identifier">nil?</span>) <span class="ruby-operator">?</span> <span class="ruby-keyword">nil</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">country</span>
1013
+ <span class="ruby-keyword">end</span></pre>
1014
+ </div><!-- get_countryname-source -->
1015
+
1016
+ </div>
1017
+
1018
+
1019
+
1020
+
1021
+ </div><!-- get_countryname-method -->
1022
+
1023
+
1024
+ <div id="method-i-get_latlng" class="method-detail ">
1025
+
1026
+ <div class="method-heading">
1027
+ <span class="method-name">get_latlng</span><span
1028
+ class="method-args">(country_code)</span>
1029
+ <span class="method-click-advice">click to toggle source</span>
1030
+ </div>
1031
+
1032
+
1033
+ <div class="method-description">
1034
+
1035
+ <p>This returns the [latitude,longitude] from the country code. Using the
1036
+ constant Tor::Constants::COUNLATLNG,</p>
1037
+
1038
+ <pre>or alternatively if Tor::COUNLATLNG has been defined in a program.</pre>
1039
+
1040
+
1041
+
1042
+ <div class="method-source-code" id="get_latlng-source">
1043
+ <pre><span class="ruby-comment"># File lib/tstats.rb, line 262</span>
1044
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">get_latlng</span>(<span class="ruby-identifier">country_code</span>)
1045
+ <span class="ruby-identifier">countrylatlng</span> = <span class="ruby-constant">Constants</span><span class="ruby-operator">::</span><span class="ruby-constant">COUNLATLNG</span>
1046
+ <span class="ruby-keyword">if</span> (<span class="ruby-keyword">defined?</span> <span class="ruby-constant">COUNLATLNG</span>)
1047
+ <span class="ruby-keyword">if</span> (<span class="ruby-constant">COUNLATLNG</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">include?</span> <span class="ruby-identifier">country_code</span>)
1048
+ <span class="ruby-identifier">lat</span>= <span class="ruby-constant">COUNLATLNG</span>[<span class="ruby-identifier">country_code</span>][<span class="ruby-value">:lat</span>]
1049
+ <span class="ruby-identifier">lng</span>= <span class="ruby-constant">COUNLATLNG</span>[<span class="ruby-identifier">country_code</span>][<span class="ruby-value">:lng</span>]
1050
+ <span class="ruby-keyword">end</span>
1051
+ <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">countrylatlng</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">include?</span> <span class="ruby-identifier">country_code</span>
1052
+ <span class="ruby-identifier">lat</span>=<span class="ruby-identifier">countrylatlng</span>[<span class="ruby-identifier">country_code</span>][<span class="ruby-value">:lat</span>]
1053
+ <span class="ruby-identifier">lng</span>=<span class="ruby-identifier">countrylatlng</span>[<span class="ruby-identifier">country_code</span>][<span class="ruby-value">:lng</span>]
1054
+ <span class="ruby-keyword">else</span>
1055
+ <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{country_code}, #{get_countryname(country_code)} - not in the country-latitude file, using cordinates(0,0)&quot;</span>
1056
+ <span class="ruby-identifier">lat</span>=<span class="ruby-value">0.0</span>
1057
+ <span class="ruby-identifier">lng</span>=<span class="ruby-value">0.0</span>
1058
+ <span class="ruby-keyword">end</span>
1059
+ [<span class="ruby-identifier">lat</span>,<span class="ruby-identifier">lng</span>]
1060
+ <span class="ruby-keyword">end</span></pre>
1061
+ </div><!-- get_latlng-source -->
1062
+
1063
+ </div>
1064
+
1065
+
1066
+
1067
+
1068
+ </div><!-- get_latlng-method -->
1069
+
1070
+
1071
+ <div id="method-i-get_uniqid" class="method-detail ">
1072
+
1073
+ <div class="method-heading">
1074
+ <span class="method-name">get_uniqid</span><span
1075
+ class="method-args">(countryfilter,*platform)</span>
1076
+ <span class="method-click-advice">click to toggle source</span>
1077
+ </div>
1078
+
1079
+
1080
+ <div class="method-description">
1081
+
1082
+ <p>This returns the id of uniq identities in the database</p>
1083
+
1084
+ <p>@example Get Uniq id of ORs in the UK</p>
1085
+
1086
+ <pre>Tor::Stats.Obj.get_uniqid(&quot;GB&quot;)
1087
+ Tor::Stats.Obj.get_uniqid(&quot;GB&quot;,&quot;WINDOWS&quot;)
1088
+ Tor::Stats.Obj.get_uniqid([&quot;GB&quot;,&quot;FR&quot;,DE&quot;] , [&quot;UNIX&quot;,&quot;LINUX&quot;])</pre>
1089
+
1090
+
1091
+
1092
+ <div class="method-source-code" id="get_uniqid-source">
1093
+ <pre><span class="ruby-comment"># File lib/tstats.rb, line 289</span>
1094
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">get_uniqid</span>(<span class="ruby-identifier">countryfilter</span>,*<span class="ruby-identifier">platform</span>)
1095
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">platform</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">platform</span><span class="ruby-operator">==</span>[<span class="ruby-string">&quot;ALL&quot;</span>] <span class="ruby-keyword">or</span> <span class="ruby-identifier">platform</span><span class="ruby-operator">==</span>[<span class="ruby-string">&quot;All&quot;</span>]
1096
+ <span class="ruby-identifier">torlocations</span> = <span class="ruby-constant">Router</span>.<span class="ruby-identifier">where</span>(<span class="ruby-value">:country_code=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">countryfilter</span>)
1097
+ <span class="ruby-keyword">else</span>
1098
+ <span class="ruby-identifier">torlocations</span> = <span class="ruby-constant">Router</span>.<span class="ruby-identifier">where</span>(<span class="ruby-value">:platform=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">platform</span>,<span class="ruby-value">:country_code=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">countryfilter</span>)
1099
+ <span class="ruby-keyword">end</span>
1100
+ <span class="ruby-identifier">identitygroup</span> = <span class="ruby-identifier">torlocations</span>.<span class="ruby-identifier">group_by</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">fingerprint</span>}
1101
+ <span class="ruby-identifier">idarray</span> = <span class="ruby-identifier">identitygroup</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">collect</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">eachidentitykey</span><span class="ruby-operator">|</span>
1102
+ <span class="ruby-comment">#Collect just the id of the most recent location of the fingerprint</span>
1103
+ <span class="ruby-identifier">identitygroup</span>[<span class="ruby-identifier">eachidentitykey</span>].<span class="ruby-identifier">max</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">a</span>,<span class="ruby-identifier">b</span><span class="ruby-operator">|</span> <span class="ruby-identifier">a</span>.<span class="ruby-identifier">published_at</span> <span class="ruby-operator">&lt;=&gt;</span> <span class="ruby-identifier">b</span>.<span class="ruby-identifier">published_at</span>}.<span class="ruby-identifier">id</span>
1104
+ }
1105
+ <span class="ruby-keyword">end</span></pre>
1106
+ </div><!-- get_uniqid-source -->
1107
+
1108
+ </div>
1109
+
1110
+
1111
+
1112
+
1113
+ </div><!-- get_uniqid-method -->
1114
+
1115
+
1116
+ <div id="method-i-topcountries" class="method-detail ">
1117
+
1118
+ <div class="method-heading">
1119
+ <span class="method-name">topcountries</span><span
1120
+ class="method-args">(num,*platform)</span>
1121
+ <span class="method-click-advice">click to toggle source</span>
1122
+ </div>
1123
+
1124
+
1125
+ <div class="method-description">
1126
+
1127
+ <p>This returns the top n-countries. An optional platform parameter can be
1128
+ passed to this and returns an array of countries and total</p>
1129
+
1130
+ <p>@example Top n-countries <a
1131
+ href="StatsObj.html#method-i-topcountries">#topcountries</a>
1132
+ =&gt; [[<a href="http://country,total">country,total].…</a>] <a
1133
+ href="StatsObj.html#method-i-topcountries">#topcountries</a>(n, “UNIX”) <a
1134
+ href="StatsObj.html#method-i-topcountries">#topcountries</a>(n,
1135
+ [“UNIX”,“LINUX”])</p>
1136
+
1137
+
1138
+
1139
+ <div class="method-source-code" id="topcountries-source">
1140
+ <pre><span class="ruby-comment"># File lib/tstats.rb, line 229</span>
1141
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">topcountries</span>(<span class="ruby-identifier">num</span>,*<span class="ruby-identifier">platform</span>)
1142
+ <span class="ruby-identifier">countryarray</span> = <span class="ruby-identifier">country_list</span>(*<span class="ruby-identifier">platform</span>)
1143
+ <span class="ruby-identifier">top_countries</span> = <span class="ruby-identifier">country_stat</span>(<span class="ruby-identifier">countryarray</span>,*<span class="ruby-identifier">platform</span>).<span class="ruby-identifier">sort_by</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">v</span>}
1144
+ <span class="ruby-identifier">result</span> = (<span class="ruby-identifier">num</span><span class="ruby-operator">==</span><span class="ruby-value">0</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">top_countries</span>.<span class="ruby-identifier">reverse</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">top_countries</span>.<span class="ruby-identifier">last</span>(<span class="ruby-identifier">num</span>).<span class="ruby-identifier">reverse</span>
1145
+ <span class="ruby-keyword">end</span></pre>
1146
+ </div><!-- topcountries-source -->
1147
+
1148
+ </div>
1149
+
1150
+
1151
+
1152
+
1153
+ </div><!-- topcountries-method -->
1154
+
1155
+
1156
+ <div id="method-i-topcountries_uniq" class="method-detail ">
1157
+
1158
+ <div class="method-heading">
1159
+ <span class="method-name">topcountries_uniq</span><span
1160
+ class="method-args">(num,*platform)</span>
1161
+ <span class="method-click-advice">click to toggle source</span>
1162
+ </div>
1163
+
1164
+
1165
+ <div class="method-description">
1166
+
1167
+ <p>This returns the top n-countries. An optional platform parameter can be
1168
+ passed to this and returns an array of countries and total</p>
1169
+
1170
+ <p>@example Top n-countries <a
1171
+ href="StatsObj.html#method-i-topcountries_uniq">#topcountries_uniq</a>
1172
+ =&gt; [[<a href="http://country,total">country,total].…</a>] <a
1173
+ href="StatsObj.html#method-i-topcountries_uniq">#topcountries_uniq</a>(n,
1174
+ “UNIX”) <a
1175
+ href="StatsObj.html#method-i-topcountries_uniq">#topcountries_uniq</a>(n,
1176
+ [“UNIX”,“LINUX”])</p>
1177
+
1178
+
1179
+
1180
+ <div class="method-source-code" id="topcountries_uniq-source">
1181
+ <pre><span class="ruby-comment"># File lib/tstats.rb, line 243</span>
1182
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">topcountries_uniq</span>(<span class="ruby-identifier">num</span>,*<span class="ruby-identifier">platform</span>)
1183
+ <span class="ruby-identifier">countryarray</span> = <span class="ruby-identifier">country_list</span>(*<span class="ruby-identifier">platform</span>)
1184
+ <span class="ruby-identifier">top_countries</span> = <span class="ruby-identifier">country_stat_uniq</span>(<span class="ruby-identifier">countryarray</span>,*<span class="ruby-identifier">platform</span>).<span class="ruby-identifier">sort_by</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">v</span>}
1185
+ <span class="ruby-identifier">result</span> = (<span class="ruby-identifier">num</span><span class="ruby-operator">==</span><span class="ruby-value">0</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">top_countries</span>.<span class="ruby-identifier">reverse</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">top_countries</span>.<span class="ruby-identifier">last</span>(<span class="ruby-identifier">num</span>).<span class="ruby-identifier">reverse</span>
1186
+ <span class="ruby-keyword">end</span></pre>
1187
+ </div><!-- topcountries_uniq-source -->
1188
+
1189
+ </div>
1190
+
1191
+
1192
+
1193
+
1194
+ </div><!-- topcountries_uniq-method -->
1195
+
1196
+
1197
+ </section><!-- public-instance-method-details -->
1198
+
1199
+ </section><!-- 5Buntitled-5D -->
1200
+
1201
+ </div><!-- documentation -->
1202
+
1203
+
1204
+ <footer id="validator-badges">
1205
+ <p><a href="http://validator.w3.org/check/referer">[Validate]</a>
1206
+ <p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.11.
1207
+ <p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
1208
+ </footer>
1209
+