tormanager 0.1.0 → 0.2.0

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 (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +84 -60
  3. data/lib/tormanager/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 04505aabbc5658c80ee5124866e5fa939a1d42d1
4
- data.tar.gz: 7798de7e4ac6228cc2afd6e2bf68873d94fcbc82
3
+ metadata.gz: ae9cd4db1d87b48b12d3c7da7f27ec8f73a03fd9
4
+ data.tar.gz: bc8871a5eca69b0ab3d66b283ada7094138901c7
5
5
  SHA512:
6
- metadata.gz: cf53e41f6cab0da777462c69a526e63de3dc5802fac1b07b82425d5ba66cadcd3f62b115fb948354e4dcbd9417aa15d5eb8410686558a86a9cfe381191c87726
7
- data.tar.gz: e7828a3ae09c95e22ee3f04dbb5abcf71efc7264a024da5f6ec441e3f3f35b40cd58c0973b8f1022d784b2898cc4e029c327651cb343344edc00e26ad350ab90
6
+ metadata.gz: bbfdd160272d2bc25b8b29e67afaffbf9ef642c233e86ad541a80d8205df2bf188d97a8a501aaa9770222cb08cab10fa1c5f18369082449cf03c8a24962296d1
7
+ data.tar.gz: 6dd60fc33690fd71c64c62a8181311b81389af36f4c3d58c57689028c75b5c1abaa638b862e42e02d44aae772f951e9fda1b21acc8cea6c6f440db01899cf47b
data/README.md CHANGED
@@ -35,11 +35,13 @@ This section shows how to start, stop and manage Tor processes.
35
35
 
36
36
  Start a Tor process with default settings:
37
37
 
38
- tor_process = TorManager::TorProcess.new
39
- tor_process.start
40
-
41
- #you can get the control password for the Tor process if you want:
42
- tor_process.settings[:control_password]
38
+ ```ruby
39
+ tor_process = TorManager::TorProcess.new
40
+ tor_process.start
41
+
42
+ #you can get the control password for the Tor process if you want:
43
+ tor_process.settings[:control_password]
44
+ ```
43
45
 
44
46
  By default, the Tor process will use using port `9050` and control port `50500` and
45
47
  will be spawned using [Eye](https://github.com/kostya/eye) ensuring that the process remains in a healthy state.
@@ -55,25 +57,29 @@ More information can be found in the `TorManager::TorProcess` parameters table b
55
57
 
56
58
  You can also spawn a Tor process with control over parameters:
57
59
 
58
- tor_process =
59
- TorManager::TorProcess.new tor_port: 9051,
60
- control_port: 50501,
61
- pid_dir: '/my/pid/dir',
62
- log_dir: '/my/log/dir',
63
- tor_data_dir: '/my/tor/datadir',
64
- tor_new_circuit_period: 120,
65
- max_tor_memory_usage_mb: 400,
66
- max_tor_cpu_percentage: 15,
67
- control_password: 'mycontrolpass',
68
- eye_logging: true,
69
- tor_logging: true
70
- tor_process.start
60
+ ```ruby
61
+ tor_process =
62
+ TorManager::TorProcess.new tor_port: 9051,
63
+ control_port: 50501,
64
+ pid_dir: '/my/pid/dir',
65
+ log_dir: '/my/log/dir',
66
+ tor_data_dir: '/my/tor/datadir',
67
+ tor_new_circuit_period: 120,
68
+ max_tor_memory_usage_mb: 400,
69
+ max_tor_cpu_percentage: 15,
70
+ control_password: 'mycontrolpass',
71
+ eye_logging: true,
72
+ tor_logging: true
73
+ tor_process.start
74
+ ```
71
75
 
72
76
  See the table below for more info.
73
77
 
74
78
  When done with the Tor process, `stop` it:
75
79
 
76
- tor_process.stop
80
+ ```ruby
81
+ tor_process.stop
82
+ ```
77
83
 
78
84
  The following table describes the `TorManager::TorProcess` parameters:
79
85
 
@@ -98,15 +104,21 @@ The following table describes the `TorManager::TorProcess` parameters:
98
104
 
99
105
  To stop any Tor instances that have been previously started by Tor Manager but were not stopped (say in the event of a parent process crash) **_††_**:
100
106
 
101
- TorProcess.stop_obsolete_processes
107
+ ```ruby
108
+ TorManager::TorProcess.stop_obsolete_processes
109
+ ```
102
110
 
103
111
  Query whether Tor Manager has any Tor processes running on a particular port **_††_**:
104
112
 
105
- TorProcess.tor_running_on? port: 9050
113
+ ```ruby
114
+ TorManager::TorProcess.tor_running_on? port: 9050
115
+ ```
106
116
 
107
117
  Query whether Tor Manager has any Tor processes running on a particular port associated to a particular parent ruby pid **_††_**:
108
118
 
109
- TorProcess.tor_running_on? port: 9050, parent_pid: 12345
119
+ ```ruby
120
+ TorManager::TorProcess.tor_running_on? port: 9050, parent_pid: 12345
121
+ ```
110
122
 
111
123
  **_††_** Note that this command applies only to Tor processes that were started by Tor Manager.
112
124
  Tor processes that have been started external to Tor Manager will not be impacted.
@@ -121,20 +133,24 @@ Once you have a `TorProcess` started, you can:
121
133
 
122
134
  The remaining examples assume that you have instantiated a `TorProcess` ie:
123
135
 
124
- tor_process = TorManager::TorProcess.new
125
- tor_process.start
136
+ ```ruby
137
+ tor_process = TorManager::TorProcess.new
138
+ tor_process.start
139
+ ```
126
140
 
127
141
  #### Proxy Through Tor
128
-
129
- tor_proxy = TorManager::Proxy.new tor_process: tor_process
130
- tor_proxy.proxy do
131
- tor_ip = RestClient::Request.execute(
132
- method: :get,
133
- url: 'http://bot.whatismyipaddress.com').to_str
134
- end
135
- my_ip = RestClient::Request.execute(
136
- method: :get,
137
- url: 'http://bot.whatismyipaddress.com').to_str
142
+
143
+ ```ruby
144
+ tor_proxy = TorManager::Proxy.new tor_process: tor_process
145
+ tor_proxy.proxy do
146
+ tor_ip = RestClient::Request.execute(
147
+ method: :get,
148
+ url: 'http://bot.whatismyipaddress.com').to_str
149
+ end
150
+ my_ip = RestClient::Request.execute(
151
+ method: :get,
152
+ url: 'http://bot.whatismyipaddress.com').to_str
153
+ ```
138
154
 
139
155
  Note that in the above code the `RestClient::Request` returning `tor_ip` is routed through the Tor endpoint because it is yielded
140
156
  through the `TorManager::Proxy#proxy` block. The following request returning `my_ip` will not be routed through the Tor endpoint
@@ -143,47 +159,55 @@ hence returning your current IP address.
143
159
  You could route [Capybara](https://github.com/teamcapybara/capybara) requests through the proxy (just make sure you use the `:poltergeist` driver and set the proxy
144
160
  to use the Tor socks proxy):
145
161
 
146
- Capybara.default_driver = :poltergeist
147
- Capybara.register_driver :poltergeist do |app|
148
- Capybara::Poltergeist::Driver.new(app, {
149
- :phantomjs => Phantomjs.path,
150
- :phantomjs_options => ["--proxy-type=socks5", "--proxy=127.0.0.1:9050"]
151
- })
152
- end
153
- tor_proxy = TorManager::Proxy.new tor_process: tor_process
154
- tor_proxy.proxy do
155
- tor_ip = Capybara.visit('http://bot.whatismyipaddress.com').text
156
- end
162
+ ```ruby
163
+ Capybara.default_driver = :poltergeist
164
+ Capybara.register_driver :poltergeist do |app|
165
+ Capybara::Poltergeist::Driver.new(app, {
166
+ :phantomjs => Phantomjs.path,
167
+ :phantomjs_options => ["--proxy-type=socks5", "--proxy=127.0.0.1:9050"]
168
+ })
169
+ end
170
+ tor_proxy = TorManager::Proxy.new tor_process: tor_process
171
+ tor_proxy.proxy do
172
+ tor_ip = Capybara.visit('http://bot.whatismyipaddress.com').text
173
+ end
174
+ ```
157
175
 
158
176
  #### Query IP Address
159
177
 
160
178
  Query the Tor endpoint for the current IP address:
161
179
 
162
- tor_proxy = TorManager::Proxy.new tor_process: tor_process
163
- tor_ip_control =
164
- TorManager::IpAddressControl.new tor_process: tor_process,
165
- tor_proxy: tor_proxy
166
- tor_ip_control.get_ip
180
+ ```ruby
181
+ tor_proxy = TorManager::Proxy.new tor_process: tor_process
182
+ tor_ip_control =
183
+ TorManager::IpAddressControl.new tor_process: tor_process,
184
+ tor_proxy: tor_proxy
185
+ tor_ip_control.get_ip
186
+ ```
167
187
 
168
188
  When the `TorManager::IpAddressControl#get_ip` method is called, the IP address is stored in instance variable:
169
189
 
170
- tor_ip_control.ip
171
-
190
+ ```ruby
191
+ tor_ip_control.ip
192
+ ```
172
193
 
173
194
  #### Change IP Address
174
195
 
175
196
  Get a new IP address:
176
197
 
177
- tor_proxy = TorManager::Proxy.new tor_process: tor_process
178
- tor_ip_control =
179
- TorManager::IpAddressControl.new tor_process: tor_process,
180
- tor_proxy: tor_proxy
181
- tor_ip_control.get_new_ip
182
-
183
- When the `TorManager::IpAddressControl#get_new_ip` method is called, the IP address is stored in instance variable:
198
+ ```ruby
199
+ tor_proxy = TorManager::Proxy.new tor_process: tor_process
200
+ tor_ip_control =
201
+ TorManager::IpAddressControl.new tor_process: tor_process,
202
+ tor_proxy: tor_proxy
203
+ tor_ip_control.get_new_ip
204
+ ```
184
205
 
185
- tor_ip_control.ip
206
+ When the `TorManager::IpAddressControl#get_new_ip` method is called, the IP address is stored in instance variable:
186
207
 
208
+ ```ruby
209
+ tor_ip_control.ip
210
+ ```
187
211
 
188
212
  ## Contributing
189
213
 
@@ -1,3 +1,3 @@
1
1
  module TorManager
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tormanager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - joshweir