Class: Tor::HiddenService
- Inherits:
-
Object
- Object
- Tor::HiddenService
- Defined in:
- lib/tor/hidden-service.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ HiddenService
constructor
A new instance of HiddenService.
- #start ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ HiddenService
Returns a new instance of HiddenService.
10 11 12 13 |
# File 'lib/tor/hidden-service.rb', line 10 def initialize(={}) = () @base_dir = "#{@options[:temp_dir]}/tor_#{@options[:tor_control_port]}" end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/tor/hidden-service.rb', line 8 def end |
Instance Method Details
#start ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/tor/hidden-service.rb', line 15 def start generate_tor_config @pid = fork do spawn [:tor_executable], '-f', "#{@base_dir}/torrc" end Process.wait(@pid) begin @tor_pid = File.read(open("#{@base_dir}/pid")).strip.to_i rescue Errno::ENOENT "Waiting for Tor PID to appear..." sleep 1 retry end "Started Tor with PID #{@tor_pid} on control port #{@options[:tor_control_port]}" at_exit do "Killing Tor PID #{@tor_pid}..." Process.kill :SIGTERM, @tor_pid Process.wait end end |