tor_extend 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Change.log +12 -0
- data/ReadME.txt +190 -0
- data/doc/ReadME_txt.html +301 -0
- data/doc/Tor.html +140 -0
- data/doc/Tor/Bridge.html +145 -0
- data/doc/Tor/CachedDesc.html +472 -0
- data/doc/Tor/Constants.html +185 -0
- data/doc/Tor/Router.html +146 -0
- data/doc/Tor/StatsObj.html +1209 -0
- data/doc/Tor/TController.html +1111 -0
- data/doc/created.rid +7 -0
- data/doc/images/add.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +90 -0
- data/doc/js/darkfish.js +153 -0
- data/doc/js/jquery.js +18 -0
- data/doc/js/navigation.js +142 -0
- data/doc/js/search.js +94 -0
- data/doc/js/search_index.js +1 -0
- data/doc/js/searcher.js +228 -0
- data/doc/lib/constants_rb.html +96 -0
- data/doc/lib/httpmod_rb.html +95 -0
- data/doc/lib/tcontroller_rb.html +93 -0
- data/doc/lib/tor_extend_rb.html +97 -0
- data/doc/lib/tstats_rb.html +93 -0
- data/doc/rdoc.css +543 -0
- data/doc/table_of_contents.html +159 -0
- data/lib/constants.rb +106 -0
- data/lib/httpmod.rb +89 -0
- data/lib/tcontroller.rb +475 -0
- data/lib/tor_extend.rb +189 -0
- data/lib/tstats.rb +514 -0
- data/tor_extend.gemspec +26 -0
- metadata +138 -0
data/doc/Tor.html
ADDED
@@ -0,0 +1,140 @@
|
|
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</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/tor_extend.rb
|
51
|
+
<li>lib/tstats.rb
|
52
|
+
<li>lib/tcontroller.rb
|
53
|
+
</ul>
|
54
|
+
</nav>
|
55
|
+
|
56
|
+
|
57
|
+
</div>
|
58
|
+
|
59
|
+
<div id="class-metadata">
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
</div>
|
65
|
+
|
66
|
+
<div id="project-metadata">
|
67
|
+
<nav id="fileindex-section" class="section project-section">
|
68
|
+
<h3 class="section-header">Pages</h3>
|
69
|
+
|
70
|
+
<ul>
|
71
|
+
|
72
|
+
<li class="file"><a href="./ReadME_txt.html">ReadME</a>
|
73
|
+
|
74
|
+
</ul>
|
75
|
+
</nav>
|
76
|
+
|
77
|
+
<nav id="classindex-section" class="section project-section">
|
78
|
+
<h3 class="section-header">Class and Module Index</h3>
|
79
|
+
|
80
|
+
<ul class="link-list">
|
81
|
+
|
82
|
+
<li><a href="./Tor.html">Tor</a>
|
83
|
+
|
84
|
+
<li><a href="./Tor/Bridge.html">Tor::Bridge</a>
|
85
|
+
|
86
|
+
<li><a href="./Tor/CachedDesc.html">Tor::CachedDesc</a>
|
87
|
+
|
88
|
+
<li><a href="./Tor/Constants.html">Tor::Constants</a>
|
89
|
+
|
90
|
+
<li><a href="./Tor/Router.html">Tor::Router</a>
|
91
|
+
|
92
|
+
<li><a href="./Tor/StatsObj.html">Tor::StatsObj</a>
|
93
|
+
|
94
|
+
<li><a href="./Tor/TController.html">Tor::TController</a>
|
95
|
+
|
96
|
+
</ul>
|
97
|
+
</nav>
|
98
|
+
|
99
|
+
</div>
|
100
|
+
</nav>
|
101
|
+
|
102
|
+
<div id="documentation">
|
103
|
+
<h1 class="module">module Tor</h1>
|
104
|
+
|
105
|
+
<div id="description" class="description">
|
106
|
+
|
107
|
+
<p><a href="Tor.html">Tor</a> includes the <a
|
108
|
+
href="Tor/TController.html">TController</a> class, which inherits the
|
109
|
+
methods from Bendiken's <a
|
110
|
+
href="http://cypherpunk.rubyforge.org/tor/">page</a> Tor::Controller class
|
111
|
+
and extends it with more methods. You are responsible for how you use the
|
112
|
+
code. See the Unlicence in Bendiken's tor-ruby gem.</p>
|
113
|
+
|
114
|
+
</div><!-- description -->
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
<!-- Methods -->
|
129
|
+
|
130
|
+
</section><!-- 5Buntitled-5D -->
|
131
|
+
|
132
|
+
</div><!-- documentation -->
|
133
|
+
|
134
|
+
|
135
|
+
<footer id="validator-badges">
|
136
|
+
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
137
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.11.
|
138
|
+
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
139
|
+
</footer>
|
140
|
+
|
data/doc/Tor/Bridge.html
ADDED
@@ -0,0 +1,145 @@
|
|
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::Bridge</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::Bridge</h1>
|
108
|
+
|
109
|
+
<div id="description" class="description">
|
110
|
+
|
111
|
+
<p><a href="Bridge.html">Tor::Bridge</a> is a class for the active record
|
112
|
+
database holding the ip-addresses and port for the bridges discovered using
|
113
|
+
the Tor::TController.getbridges.</p>
|
114
|
+
|
115
|
+
<p><strong>Show all Bridges in the database</strong></p>
|
116
|
+
|
117
|
+
<pre>Tor::Bridge.all</pre>
|
118
|
+
|
119
|
+
</div><!-- description -->
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
<!-- Methods -->
|
134
|
+
|
135
|
+
</section><!-- 5Buntitled-5D -->
|
136
|
+
|
137
|
+
</div><!-- documentation -->
|
138
|
+
|
139
|
+
|
140
|
+
<footer id="validator-badges">
|
141
|
+
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
142
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.11.
|
143
|
+
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
144
|
+
</footer>
|
145
|
+
|
@@ -0,0 +1,472 @@
|
|
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::CachedDesc</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">Object
|
63
|
+
|
64
|
+
</nav>
|
65
|
+
|
66
|
+
|
67
|
+
<!-- Method Quickref -->
|
68
|
+
<nav id="method-list-section" class="section">
|
69
|
+
<h3 class="section-header">Methods</h3>
|
70
|
+
|
71
|
+
<ul class="link-list">
|
72
|
+
|
73
|
+
<li><a href="#method-c-new">::new</a>
|
74
|
+
|
75
|
+
<li><a href="#method-i-dbconnect">#dbconnect</a>
|
76
|
+
|
77
|
+
<li><a href="#method-i-get_geoiprecord">#get_geoiprecord</a>
|
78
|
+
|
79
|
+
<li><a href="#method-i-ors">#ors</a>
|
80
|
+
|
81
|
+
<li><a href="#method-i-readall">#readall</a>
|
82
|
+
|
83
|
+
<li><a href="#method-i-stat">#stat</a>
|
84
|
+
|
85
|
+
</ul>
|
86
|
+
</nav>
|
87
|
+
|
88
|
+
</div>
|
89
|
+
|
90
|
+
<div id="project-metadata">
|
91
|
+
<nav id="fileindex-section" class="section project-section">
|
92
|
+
<h3 class="section-header">Pages</h3>
|
93
|
+
|
94
|
+
<ul>
|
95
|
+
|
96
|
+
<li class="file"><a href="../ReadME_txt.html">ReadME</a>
|
97
|
+
|
98
|
+
</ul>
|
99
|
+
</nav>
|
100
|
+
|
101
|
+
<nav id="classindex-section" class="section project-section">
|
102
|
+
<h3 class="section-header">Class and Module Index</h3>
|
103
|
+
|
104
|
+
<ul class="link-list">
|
105
|
+
|
106
|
+
<li><a href="../Tor.html">Tor</a>
|
107
|
+
|
108
|
+
<li><a href="../Tor/Bridge.html">Tor::Bridge</a>
|
109
|
+
|
110
|
+
<li><a href="../Tor/CachedDesc.html">Tor::CachedDesc</a>
|
111
|
+
|
112
|
+
<li><a href="../Tor/Constants.html">Tor::Constants</a>
|
113
|
+
|
114
|
+
<li><a href="../Tor/Router.html">Tor::Router</a>
|
115
|
+
|
116
|
+
<li><a href="../Tor/StatsObj.html">Tor::StatsObj</a>
|
117
|
+
|
118
|
+
<li><a href="../Tor/TController.html">Tor::TController</a>
|
119
|
+
|
120
|
+
</ul>
|
121
|
+
</nav>
|
122
|
+
|
123
|
+
</div>
|
124
|
+
</nav>
|
125
|
+
|
126
|
+
<div id="documentation">
|
127
|
+
<h1 class="class">class Tor::CachedDesc</h1>
|
128
|
+
|
129
|
+
<div id="description" class="description">
|
130
|
+
|
131
|
+
<p><a href="CachedDesc.html">Tor::CachedDesc</a> is a class used to read
|
132
|
+
cached descriptors into a database. The ip address, fingerprint, platform,
|
133
|
+
country, latitude and longitude.</p>
|
134
|
+
|
135
|
+
<p>@example Create database and read cached desciptor into it
|
136
|
+
cached_descriptor = <a href="CachedDesc.html#method-c-new">::new</a> <a
|
137
|
+
href="CachedDesc.html#method-i-dbconnect">#dbconnect</a> <a
|
138
|
+
href="CachedDesc.html#method-i-dbconnect">#dbconnect</a>( { :adapter =>
|
139
|
+
“sqlite3”,:database => “db.sqlite3”} ) <a
|
140
|
+
href="CachedDesc.html#method-i-readall">#readall</a>(“cached_descriptor_filename”)
|
141
|
+
<a href="CachedDesc.html#method-i-ors">#ors</a> <a
|
142
|
+
href="CachedDesc.html#method-i-ors">#ors</a>.all</p>
|
143
|
+
|
144
|
+
</div><!-- description -->
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
<!-- Methods -->
|
159
|
+
|
160
|
+
<section id="public-class-5Buntitled-5D-method-details" class="method-section section">
|
161
|
+
<h3 class="section-header">Public Class Methods</h3>
|
162
|
+
|
163
|
+
|
164
|
+
<div id="method-c-new" class="method-detail ">
|
165
|
+
|
166
|
+
<div class="method-heading">
|
167
|
+
<span class="method-name">new</span><span
|
168
|
+
class="method-args">(geoip_path)</span>
|
169
|
+
<span class="method-click-advice">click to toggle source</span>
|
170
|
+
</div>
|
171
|
+
|
172
|
+
|
173
|
+
<div class="method-description">
|
174
|
+
|
175
|
+
<p>This initialises the stat attribute of the <a
|
176
|
+
href="CachedDesc.html">CachedDesc</a> class that can be used to get data
|
177
|
+
from <a href="Router.html">Tor::Router</a></p>
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
<div class="method-source-code" id="new-source">
|
182
|
+
<pre><span class="ruby-comment"># File lib/tor_extend.rb, line 53</span>
|
183
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">geoip_path</span>)
|
184
|
+
<span class="ruby-ivar">@stat</span> = <span class="ruby-constant">StatsObj</span>.<span class="ruby-identifier">new</span>
|
185
|
+
<span class="ruby-comment"># Tor::CachedDesc#geoipdb is an instance of GeoIP with the active database</span>
|
186
|
+
<span class="ruby-ivar">@geoipdb</span> = <span class="ruby-constant">GeoIP</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">geoip_path</span>[<span class="ruby-value">0</span>])
|
187
|
+
<span class="ruby-comment"># Tor::CachedDesc#geoipdb2 acts as a backup if records are not present in Tor::CachedDesc#geoipdb</span>
|
188
|
+
<span class="ruby-ivar">@geoipdb2</span> = <span class="ruby-constant">GeoIP</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">geoip_path</span>[<span class="ruby-value">1</span>])
|
189
|
+
<span class="ruby-keyword">end</span></pre>
|
190
|
+
</div><!-- new-source -->
|
191
|
+
|
192
|
+
</div>
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
</div><!-- new-method -->
|
198
|
+
|
199
|
+
|
200
|
+
</section><!-- public-class-method-details -->
|
201
|
+
|
202
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section section">
|
203
|
+
<h3 class="section-header">Public Instance Methods</h3>
|
204
|
+
|
205
|
+
|
206
|
+
<div id="method-i-dbconnect" class="method-detail ">
|
207
|
+
|
208
|
+
<div class="method-heading">
|
209
|
+
<span class="method-name">dbconnect</span><span
|
210
|
+
class="method-args">(*dbconfig)</span>
|
211
|
+
<span class="method-click-advice">click to toggle source</span>
|
212
|
+
</div>
|
213
|
+
|
214
|
+
|
215
|
+
<div class="method-description">
|
216
|
+
|
217
|
+
<p>Tor::dbconnect() method connects using the optional database config passed
|
218
|
+
as argument. It creates an sqlite3 file by default called db.sqlite3, and a
|
219
|
+
table called routers. A table called routers is created in an existing
|
220
|
+
database if it does not already exist.</p>
|
221
|
+
|
222
|
+
<p><strong>Connecting to a database</strong></p>
|
223
|
+
|
224
|
+
<pre class="ruby"><span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">CachedDesc</span>.<span class="ruby-identifier">dbconnect</span>
|
225
|
+
<span class="ruby-constant">Tor</span><span class="ruby-operator">::</span><span class="ruby-constant">CachedDesc</span>.<span class="ruby-identifier">dbconnect</span>( {:<span class="ruby-identifier">adapter</span> =<span class="ruby-operator">></span> <span class="ruby-string">"sqlite3"</span>,:<span class="ruby-identifier">database</span> =<span class="ruby-operator">></span> <span class="ruby-string">"db_name_here"</span>} )
|
226
|
+
</pre>
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
<div class="method-source-code" id="dbconnect-source">
|
231
|
+
<pre><span class="ruby-comment"># File lib/tor_extend.rb, line 75</span>
|
232
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">dbconnect</span>(*<span class="ruby-identifier">dbconfig</span>)
|
233
|
+
<span class="ruby-identifier">dbconfig</span> = [{<span class="ruby-value">:adapter</span> =<span class="ruby-operator">></span> <span class="ruby-string">"sqlite3"</span>,<span class="ruby-value">:database</span> =<span class="ruby-operator">></span> <span class="ruby-string">"db.sqlite3"</span>}] <span class="ruby-keyword">if</span> <span class="ruby-identifier">dbconfig</span>.<span class="ruby-identifier">empty?</span>
|
234
|
+
<span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">establish_connection</span>(<span class="ruby-identifier">dbconfig</span>[<span class="ruby-value">0</span>])
|
235
|
+
<span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">connection</span>.<span class="ruby-identifier">table_exists?</span>(<span class="ruby-string">'routers'</span>)
|
236
|
+
<span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Schema</span>.<span class="ruby-identifier">define</span> <span class="ruby-keyword">do</span>
|
237
|
+
<span class="ruby-identifier">create_table</span> <span class="ruby-value">:routers</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span>
|
238
|
+
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">string</span> <span class="ruby-value">:ipaddr</span>
|
239
|
+
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">text</span> <span class="ruby-value">:platform</span>
|
240
|
+
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">string</span> <span class="ruby-value">:fingerprint</span>
|
241
|
+
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">string</span> <span class="ruby-value">:city</span>
|
242
|
+
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">string</span> <span class="ruby-value">:country</span>
|
243
|
+
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">string</span> <span class="ruby-value">:country_code</span>
|
244
|
+
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">string</span> <span class="ruby-value">:continent</span>
|
245
|
+
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">decimal</span> <span class="ruby-value">:lat</span>
|
246
|
+
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">decimal</span> <span class="ruby-value">:lng</span>
|
247
|
+
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">datetime</span> <span class="ruby-value">:published_at</span>
|
248
|
+
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">timestamps</span>
|
249
|
+
<span class="ruby-keyword">end</span>
|
250
|
+
<span class="ruby-identifier">create_table</span> <span class="ruby-value">:bridges</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span>
|
251
|
+
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">string</span> <span class="ruby-value">:ipaddr</span>
|
252
|
+
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">integer</span> <span class="ruby-value">:port</span>
|
253
|
+
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">decimal</span> <span class="ruby-value">:lat</span>
|
254
|
+
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">decimal</span> <span class="ruby-value">:lng</span>
|
255
|
+
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">timestamps</span>
|
256
|
+
<span class="ruby-keyword">end</span>
|
257
|
+
<span class="ruby-keyword">end</span>
|
258
|
+
<span class="ruby-keyword">end</span>
|
259
|
+
<span class="ruby-keyword">end</span></pre>
|
260
|
+
</div><!-- dbconnect-source -->
|
261
|
+
|
262
|
+
</div>
|
263
|
+
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
</div><!-- dbconnect-method -->
|
268
|
+
|
269
|
+
|
270
|
+
<div id="method-i-get_geoiprecord" class="method-detail ">
|
271
|
+
|
272
|
+
<div class="method-heading">
|
273
|
+
<span class="method-name">get_geoiprecord</span><span
|
274
|
+
class="method-args">(ipaddr)</span>
|
275
|
+
<span class="method-click-advice">click to toggle source</span>
|
276
|
+
</div>
|
277
|
+
|
278
|
+
|
279
|
+
<div class="method-description">
|
280
|
+
|
281
|
+
<p>This returns the Geoip record from one of the database files used in <a
|
282
|
+
href="CachedDesc.html">Tor::CachedDesc</a>.</p>
|
283
|
+
|
284
|
+
|
285
|
+
|
286
|
+
<div class="method-source-code" id="get_geoiprecord-source">
|
287
|
+
<pre><span class="ruby-comment"># File lib/tor_extend.rb, line 116</span>
|
288
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">get_geoiprecord</span>(<span class="ruby-identifier">ipaddr</span>)
|
289
|
+
<span class="ruby-identifier">or_geoip</span>=<span class="ruby-ivar">@geoipdb</span>.<span class="ruby-identifier">city</span>(<span class="ruby-identifier">ipaddr</span>)
|
290
|
+
<span class="ruby-identifier">or_geoip</span>=<span class="ruby-ivar">@geoipdb2</span>.<span class="ruby-identifier">city</span>(<span class="ruby-identifier">ipaddr</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">or_geoip</span><span class="ruby-operator">==</span><span class="ruby-keyword">nil</span>
|
291
|
+
<span class="ruby-identifier">or_geoip</span>
|
292
|
+
<span class="ruby-keyword">end</span></pre>
|
293
|
+
</div><!-- get_geoiprecord-source -->
|
294
|
+
|
295
|
+
</div>
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
</div><!-- get_geoiprecord-method -->
|
301
|
+
|
302
|
+
|
303
|
+
<div id="method-i-ors" class="method-detail ">
|
304
|
+
|
305
|
+
<div class="method-heading">
|
306
|
+
<span class="method-name">ors</span><span
|
307
|
+
class="method-args">()</span>
|
308
|
+
<span class="method-click-advice">click to toggle source</span>
|
309
|
+
</div>
|
310
|
+
|
311
|
+
|
312
|
+
<div class="method-description">
|
313
|
+
|
314
|
+
<p>Returns the <a href="Router.html">Router</a> database class. Allows
|
315
|
+
interation with the database as an instance of Active::Base if you know
|
316
|
+
what you’re doing.</p>
|
317
|
+
|
318
|
+
<p>Display on ORs in the database. Cacheddec.or.all</p>
|
319
|
+
|
320
|
+
|
321
|
+
|
322
|
+
<div class="method-source-code" id="ors-source">
|
323
|
+
<pre><span class="ruby-comment"># File lib/tor_extend.rb, line 109</span>
|
324
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">ors</span>
|
325
|
+
<span class="ruby-constant">Router</span>
|
326
|
+
<span class="ruby-keyword">end</span></pre>
|
327
|
+
</div><!-- ors-source -->
|
328
|
+
|
329
|
+
</div>
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
|
334
|
+
</div><!-- ors-method -->
|
335
|
+
|
336
|
+
|
337
|
+
<div id="method-i-readall" class="method-detail ">
|
338
|
+
|
339
|
+
<div class="method-heading">
|
340
|
+
<span class="method-name">readall</span><span
|
341
|
+
class="method-args">(filename)</span>
|
342
|
+
<span class="method-click-advice">click to toggle source</span>
|
343
|
+
</div>
|
344
|
+
|
345
|
+
|
346
|
+
<div class="method-description">
|
347
|
+
|
348
|
+
<p>Read a file and put all the ralated information into the <a
|
349
|
+
href="Router.html">Tor::Router</a> database.</p>
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
<div class="method-source-code" id="readall-source">
|
354
|
+
<pre><span class="ruby-comment"># File lib/tor_extend.rb, line 125</span>
|
355
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">readall</span>(<span class="ruby-identifier">filename</span>)
|
356
|
+
<span class="ruby-identifier">cacheddesc</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">filename</span>,<span class="ruby-string">'r:ISO-8859-1'</span>)
|
357
|
+
<span class="ruby-identifier">loopbreaker</span>=<span class="ruby-keyword">false</span>
|
358
|
+
|
359
|
+
<span class="ruby-keyword">until</span> <span class="ruby-identifier">loopbreaker</span><span class="ruby-operator">==</span><span class="ruby-keyword">true</span>
|
360
|
+
<span class="ruby-identifier">fileline</span> = <span class="ruby-identifier">cacheddesc</span>.<span class="ruby-identifier">gets</span>
|
361
|
+
<span class="ruby-identifier">fileline</span>.<span class="ruby-identifier">chomp!</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">fileline</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span>
|
362
|
+
<span class="ruby-keyword">case</span> <span class="ruby-identifier">fileline</span>
|
363
|
+
<span class="ruby-keyword">when</span> <span class="ruby-regexp">/^published /</span>
|
364
|
+
<span class="ruby-identifier">time_published</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">parse</span> <span class="ruby-identifier">fileline</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-string">"published "</span>,<span class="ruby-string">''</span>) <span class="ruby-comment"># downloaded_at</span>
|
365
|
+
<span class="ruby-keyword">when</span> <span class="ruby-regexp">/^router /</span>
|
366
|
+
<span class="ruby-identifier">or_ipaddr</span> = <span class="ruby-identifier">fileline</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp">/\d+\.\d+\.\d+.\d+/</span>)[<span class="ruby-value">0</span>]
|
367
|
+
<span class="ruby-keyword">when</span> <span class="ruby-regexp">/^platform /</span>
|
368
|
+
<span class="ruby-keyword">case</span> <span class="ruby-identifier">fileline</span>
|
369
|
+
<span class="ruby-keyword">when</span> <span class="ruby-regexp">/Windows/</span>
|
370
|
+
<span class="ruby-identifier">osplatform</span> =<span class="ruby-string">"WINDOWS"</span>
|
371
|
+
<span class="ruby-keyword">when</span> <span class="ruby-regexp">/SunOS/</span>
|
372
|
+
<span class="ruby-identifier">osplatform</span> =<span class="ruby-string">"SUN"</span>
|
373
|
+
<span class="ruby-keyword">when</span> <span class="ruby-regexp">/Linux/</span>,<span class="ruby-regexp">/Ubuntu/</span>
|
374
|
+
<span class="ruby-identifier">osplatform</span> =<span class="ruby-string">"LINUX"</span>
|
375
|
+
<span class="ruby-keyword">when</span> <span class="ruby-regexp">/Unix/</span>, <span class="ruby-regexp">/BSD/</span>,<span class="ruby-regexp">/DragonFly/</span>,<span class="ruby-regexp">/Darwin/</span>
|
376
|
+
<span class="ruby-identifier">osplatform</span> =<span class="ruby-string">"UNIX"</span>
|
377
|
+
<span class="ruby-keyword">else</span>
|
378
|
+
<span class="ruby-identifier">osplatform</span> =<span class="ruby-string">"OTHER"</span>
|
379
|
+
<span class="ruby-keyword">end</span>
|
380
|
+
|
381
|
+
<span class="ruby-keyword">when</span> <span class="ruby-regexp">/^opt fingerprint /</span>
|
382
|
+
<span class="ruby-identifier">or_fingerprint</span>=<span class="ruby-identifier">fileline</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">"opt fingerprint "</span>)[<span class="ruby-value">1</span>].<span class="ruby-identifier">split</span>.<span class="ruby-identifier">join</span> <span class="ruby-comment"># the fingerprint</span>
|
383
|
+
<span class="ruby-comment"># puts or_ipaddr</span>
|
384
|
+
<span class="ruby-identifier">or_geoip</span>=<span class="ruby-ivar">@geoipdb</span>.<span class="ruby-identifier">city</span>(<span class="ruby-identifier">or_ipaddr</span>)
|
385
|
+
<span class="ruby-identifier">or_geoip</span>=<span class="ruby-ivar">@geoipdb2</span>.<span class="ruby-identifier">city</span>(<span class="ruby-identifier">or_ipaddr</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">or_geoip</span><span class="ruby-operator">==</span><span class="ruby-keyword">nil</span> <span class="ruby-comment"># noticed that the august database returns nil for an address like 208.64.240.182, and smaller in size than July</span>
|
386
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">or_geoip</span>.<span class="ruby-identifier">nil?</span>
|
387
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"#{or_ipaddr} not found in both geoip databases, try get an updated one, or older one."</span>
|
388
|
+
<span class="ruby-keyword">else</span>
|
389
|
+
<span class="ruby-identifier">or_city</span> = <span class="ruby-identifier">or_geoip</span>.<span class="ruby-identifier">city_name</span>
|
390
|
+
<span class="ruby-identifier">or_country</span> = <span class="ruby-identifier">or_geoip</span>.<span class="ruby-identifier">country_name</span>
|
391
|
+
<span class="ruby-identifier">orcountry_code</span> = <span class="ruby-identifier">or_geoip</span>.<span class="ruby-identifier">country_code2</span>
|
392
|
+
<span class="ruby-identifier">orcontinent</span> = <span class="ruby-identifier">or_geoip</span>.<span class="ruby-identifier">continent_code</span>
|
393
|
+
<span class="ruby-identifier">lng</span> = <span class="ruby-identifier">or_geoip</span>.<span class="ruby-identifier">longitude</span>.<span class="ruby-identifier">to_f</span>
|
394
|
+
<span class="ruby-identifier">lat</span> = <span class="ruby-identifier">or_geoip</span>.<span class="ruby-identifier">latitude</span>.<span class="ruby-identifier">to_f</span>
|
395
|
+
<span class="ruby-identifier">tmpr</span> = <span class="ruby-constant">Router</span>.<span class="ruby-identifier">where</span>(<span class="ruby-value">:ipaddr=</span><span class="ruby-operator">></span><span class="ruby-identifier">or_ipaddr</span>).<span class="ruby-identifier">first</span>
|
396
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">tmpr</span>.<span class="ruby-identifier">nil?</span>
|
397
|
+
<span class="ruby-constant">Router</span>.<span class="ruby-identifier">create</span>(<span class="ruby-value">:ipaddr=</span><span class="ruby-operator">></span><span class="ruby-identifier">or_ipaddr</span>, <span class="ruby-value">:fingerprint=</span><span class="ruby-operator">></span><span class="ruby-identifier">or_fingerprint</span>, <span class="ruby-value">:lat=</span><span class="ruby-operator">></span><span class="ruby-identifier">lat</span>, <span class="ruby-value">:lng=</span><span class="ruby-operator">></span><span class="ruby-identifier">lng</span>, <span class="ruby-value">:platform=</span><span class="ruby-operator">></span><span class="ruby-identifier">osplatform</span>, <span class="ruby-value">:city=</span><span class="ruby-operator">></span><span class="ruby-identifier">or_city</span>,
|
398
|
+
<span class="ruby-value">:country=</span><span class="ruby-operator">></span><span class="ruby-identifier">or_country</span>, <span class="ruby-value">:continent=</span><span class="ruby-operator">></span><span class="ruby-identifier">orcontinent</span>,<span class="ruby-value">:country_code=</span><span class="ruby-operator">></span><span class="ruby-identifier">orcountry_code</span>,
|
399
|
+
<span class="ruby-value">:published_at=</span><span class="ruby-operator">></span><span class="ruby-identifier">time_published</span>)
|
400
|
+
<span class="ruby-keyword">elsif</span> <span class="ruby-identifier">time_published</span> <span class="ruby-operator">></span> <span class="ruby-identifier">tmpr</span>.<span class="ruby-identifier">published_at</span>
|
401
|
+
<span class="ruby-identifier">tmpr</span>.<span class="ruby-identifier">fingerprint</span> = <span class="ruby-identifier">or_fingerprint</span> <span class="ruby-comment"># Update fingerprint - Make sure you read newer files last</span>
|
402
|
+
<span class="ruby-identifier">tmpr</span>.<span class="ruby-identifier">lat</span> = <span class="ruby-identifier">lat</span>
|
403
|
+
<span class="ruby-identifier">tmpr</span>.<span class="ruby-identifier">lng</span> = <span class="ruby-identifier">lng</span>
|
404
|
+
<span class="ruby-identifier">tmpr</span>.<span class="ruby-identifier">platform</span>=<span class="ruby-identifier">osplatform</span>
|
405
|
+
<span class="ruby-identifier">tmpr</span>.<span class="ruby-identifier">country</span>=<span class="ruby-identifier">or_country</span>
|
406
|
+
<span class="ruby-identifier">tmpr</span>.<span class="ruby-identifier">save</span>
|
407
|
+
<span class="ruby-keyword">end</span>
|
408
|
+
<span class="ruby-keyword">end</span> <span class="ruby-comment"># if orgeoip.nil?</span>
|
409
|
+
<span class="ruby-keyword">when</span> <span class="ruby-keyword">nil</span>
|
410
|
+
<span class="ruby-comment"># gets returns nil for EOF</span>
|
411
|
+
<span class="ruby-identifier">loopbreaker</span>=<span class="ruby-keyword">true</span>
|
412
|
+
<span class="ruby-identifier">cacheddesc</span>.<span class="ruby-identifier">close</span>
|
413
|
+
<span class="ruby-keyword">end</span>
|
414
|
+
<span class="ruby-keyword">end</span> <span class="ruby-comment"># end of read file until eof</span>
|
415
|
+
|
416
|
+
<span class="ruby-keyword">end</span></pre>
|
417
|
+
</div><!-- readall-source -->
|
418
|
+
|
419
|
+
</div>
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
|
424
|
+
</div><!-- readall-method -->
|
425
|
+
|
426
|
+
|
427
|
+
<div id="method-i-stat" class="method-detail ">
|
428
|
+
|
429
|
+
<div class="method-heading">
|
430
|
+
<span class="method-name">stat</span><span
|
431
|
+
class="method-args">()</span>
|
432
|
+
<span class="method-click-advice">click to toggle source</span>
|
433
|
+
</div>
|
434
|
+
|
435
|
+
|
436
|
+
<div class="method-description">
|
437
|
+
|
438
|
+
<p>This initialises the stat attribute of the <a
|
439
|
+
href="CachedDesc.html">CachedDesc</a> class that can be used to get data
|
440
|
+
from <a href="Router.html">Tor::Router</a> It returns a <a
|
441
|
+
href="StatsObj.html">Tor::StatsObj</a></p>
|
442
|
+
|
443
|
+
|
444
|
+
|
445
|
+
<div class="method-source-code" id="stat-source">
|
446
|
+
<pre><span class="ruby-comment"># File lib/tor_extend.rb, line 64</span>
|
447
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">stat</span>
|
448
|
+
<span class="ruby-ivar">@stat</span>
|
449
|
+
<span class="ruby-keyword">end</span></pre>
|
450
|
+
</div><!-- stat-source -->
|
451
|
+
|
452
|
+
</div>
|
453
|
+
|
454
|
+
|
455
|
+
|
456
|
+
|
457
|
+
</div><!-- stat-method -->
|
458
|
+
|
459
|
+
|
460
|
+
</section><!-- public-instance-method-details -->
|
461
|
+
|
462
|
+
</section><!-- 5Buntitled-5D -->
|
463
|
+
|
464
|
+
</div><!-- documentation -->
|
465
|
+
|
466
|
+
|
467
|
+
<footer id="validator-badges">
|
468
|
+
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
469
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.11.
|
470
|
+
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
471
|
+
</footer>
|
472
|
+
|