torrific 0.0.2 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Torrific
2
2
 
3
- A wrapper to 'tor' gem for change Tor identity from the command line
3
+ A wrapper to 'tor' gem for change Tor identity from the command line.
4
+ For this program to work correctly, Tor cli should be installed and the
5
+ ControlPort part of the torrc file should be uncommented.
4
6
 
5
7
  ## Installation
6
8
 
@@ -22,9 +24,11 @@ torrific [options]
22
24
 
23
25
  ### Options
24
26
 
25
- * host: Tor control host
26
- * port: Tor control port
27
- * password: Tor control authentication password
27
+ * host: Tor control host(default is 127.0.0.1)
28
+ * port: Tor control port(default is 9051)
29
+ * password: Tor control authentication password(default is empty)
30
+ * d(daemonize): Daemonize the process.
31
+ * interval: Set interval for the process.
28
32
 
29
33
  ## Contributing
30
34
 
@@ -4,12 +4,28 @@ require 'torrific'
4
4
  module Torrific
5
5
  class Application
6
6
  class << self
7
- attr_accessor :password, :port, :host
7
+ attr_accessor :password, :port, :host, :interval, :daemonize, :tor_controller
8
8
  def run
9
9
  self.parse_options
10
+
11
+ Process.daemon if self.daemonize
10
12
 
11
- tor = TorControl.new(host: self.host, port: self.port, password: self.password)
12
- tor.change_ip
13
+ trap('SIGINT') do
14
+ puts "Bye Bye!"
15
+ exit
16
+ end
17
+
18
+ self.tor_controller = TorControl.new(host: self.host, port: self.port, password: self.password)
19
+
20
+ while true
21
+ self.tor_controller.change_ip
22
+ puts "Your identity has been changed."
23
+ if(self.interval && self.interval > 0)
24
+ sleep self.interval
25
+ else
26
+ break
27
+ end
28
+ end
13
29
  end
14
30
 
15
31
  def parse_options
@@ -17,18 +33,27 @@ module Torrific
17
33
  opts.banner = "Usage: torrific [options]"
18
34
 
19
35
  opts.on("--password PASSWORD",
20
- "Sets the authentication password(default is nil)") do |pass=nil|
36
+ "Sets the authentication password(default is nil)") do |pass|
21
37
  self.password = pass
22
38
  end
23
39
 
24
- opts.on("--host HOST", "Tor Control host(default is localhost)") do |host='127.0.0.1'|
40
+ opts.on("--host HOST", "Tor Control host(default is localhost)") do |host|
25
41
  self.host = host
26
42
  end
27
43
 
28
44
  opts.on("--port PORT",
29
- "Tor Control port(default is 9051).") do |port=9051|
45
+ "Tor Control port(default is 9051).") do |port|
30
46
  self.port = port
31
47
  end
48
+
49
+ opts.on("--interval INT",
50
+ "Changes identity each INT seconds.(default is only once)") do |seconds|
51
+ self.interval = seconds.to_i
52
+ end
53
+
54
+ opts.on("-d", "Daemonize the process") do
55
+ self.daemonize = true
56
+ end
32
57
  end
33
58
 
34
59
  options.parse!
@@ -12,6 +12,7 @@ module Torrific
12
12
 
13
13
  # changes the tor identity
14
14
  def change_ip
15
+ self.connect
15
16
  self.authenticate self.password
16
17
  send_command(:signal, 'NEWNYM')
17
18
  self.close
@@ -1,3 +1,3 @@
1
1
  module Torrific
2
- VERSION = "0.0.2"
2
+ VERSION = "0.9.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: torrific
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.9.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-22 00:00:00.000000000 Z
12
+ date: 2014-05-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler