Module: Tor
- Defined in:
- lib/tor.rb,
lib/tor/dnsel.rb,
lib/tor/config.rb,
lib/tor/version.rb,
lib/tor/control.rb
Overview
Defined Under Namespace
Modules: DNSEL, VERSION Classes: Config, Controller
Class Method Summary (collapse)
-
+ (Boolean) available?
Returns
trueif Tor is available,falseotherwise. -
+ (String) program_path(program_name = :tor)
Returns the path to the
torexecutable, ornilif the program could not be found in the user's currentPATHenvironment. -
+ (Boolean) running?
Returns
trueif the Tor process is running locally,falseotherwise. -
+ (String) version
Returns the Tor version number, or
nilif Tor is not available.
Class Method Details
+ (Boolean) available?
Returns true if Tor is available, false otherwise.
54 55 56 |
# File 'lib/tor.rb', line 54 def self.available? !!program_path end |
+ (String) program_path(program_name = :tor)
Returns the path to the tor executable, or nil if the program could
not be found in the user's current PATH environment.
80 81 82 83 84 85 86 |
# File 'lib/tor.rb', line 80 def self.program_path(program_name = :tor) ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| program_path = File.join(path, program_name.to_s) return program_path if File.executable?(program_path) end return nil end |
+ (Boolean) running?
Returns true if the Tor process is running locally, false otherwise.
This works by attempting to establish a Tor Control Protocol (TC)
connection to the standard control port 9051 on localhost. If Tor
hasn't been configured with the ControlPort 9051 option, this will
return false.
38 39 40 41 42 43 44 45 |
# File 'lib/tor.rb', line 38 def self.running? begin Tor::Controller.new.quit true rescue Errno::ECONNREFUSED false end end |
+ (String) version
Returns the Tor version number, or nil if Tor is not available.
65 66 67 68 69 |
# File 'lib/tor.rb', line 65 def self.version if available? && `#{program_path} --version` =~ /Tor v(\d+)\.(\d+)\.(\d+)\.(\d+)/ [$1, $2, $3, $4].join('.') end end |