Class: Hula::Socks4ProxySsh
- Inherits:
-
Object
- Object
- Hula::Socks4ProxySsh
- Includes:
- Helpers::SocketTools
- Defined in:
- lib/hula/socks4_proxy_ssh.rb
Defined Under Namespace
Classes: DieSignal, FailedToStart
Instance Attribute Summary collapse
-
#socks_host ⇒ Object
readonly
Returns the value of attribute socks_host.
-
#socks_port ⇒ Object
readonly
Returns the value of attribute socks_port.
Instance Method Summary collapse
-
#initialize(ssh_host:, ssh_username:, ssh_password:, socks_host: 'localhost', socks_port: free_port, ssh_bin: 'ssh', retry_count: 10) ⇒ Socks4ProxySsh
constructor
A new instance of Socks4ProxySsh.
- #start ⇒ Object
- #stop ⇒ Object
Methods included from Helpers::SocketTools
free_port, port_open?, wait_for_port
Constructor Details
#initialize(ssh_host:, ssh_username:, ssh_password:, socks_host: 'localhost', socks_port: free_port, ssh_bin: 'ssh', retry_count: 10) ⇒ Socks4ProxySsh
Returns a new instance of Socks4ProxySsh.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/hula/socks4_proxy_ssh.rb', line 22 def initialize( ssh_host:, ssh_username:, ssh_password:, socks_host: 'localhost', socks_port: free_port, ssh_bin: 'ssh', retry_count: 10 ) @ssh_bin = String(ssh_bin) @ssh_host = String(ssh_host) @ssh_username = String(ssh_username) @ssh_password = String(ssh_password) @socks_port = String(socks_port) @socks_host = String(socks_host) @retry_count = retry_count end |
Instance Attribute Details
#socks_host ⇒ Object (readonly)
Returns the value of attribute socks_host.
40 41 42 |
# File 'lib/hula/socks4_proxy_ssh.rb', line 40 def socks_host @socks_host end |
#socks_port ⇒ Object (readonly)
Returns the value of attribute socks_port.
40 41 42 |
# File 'lib/hula/socks4_proxy_ssh.rb', line 40 def socks_port @socks_port end |
Instance Method Details
#start ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/hula/socks4_proxy_ssh.rb', line 49 def start @thread ||= begin thread = start_ssh_socks_thread wait_for_port(:host => socks_host, :port => socks_port, timeout_seconds: 30) thread end end |
#stop ⇒ Object
42 43 44 45 46 47 |
# File 'lib/hula/socks4_proxy_ssh.rb', line 42 def stop return unless @thread @thread.raise(DieSignal) @thread.join @thread = nil end |