Class: Pair::Session::Tunnel
- Inherits:
-
Object
- Object
- Pair::Session::Tunnel
- Defined in:
- lib/pair/session/tunnel.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#tunnel ⇒ Object
readonly
Returns the value of attribute tunnel.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(options) ⇒ Tunnel
constructor
E.g.
- #open ⇒ Object
Constructor Details
#initialize(options) ⇒ Tunnel
E.g. options: {
"host_port" => 22,
"host_login" => "bjeanes",
"port" => 2222,
"bastion" => {
"host" => "bastion.pairmill.com",
"ip_address" => "12.12.12.12",
"ssh_port" => 22,
"host_user" => "host",
"join_user" => "join",
}
}
20 21 22 |
# File 'lib/pair/session/tunnel.rb', line 20 def initialize() self. = end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object (private)
56 57 58 |
# File 'lib/pair/session/tunnel.rb', line 56 def method_missing(method, *args, &block) [method.to_s] || super(method, *args, &block) end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
4 5 6 |
# File 'lib/pair/session/tunnel.rb', line 4 def @options end |
#tunnel ⇒ Object
Returns the value of attribute tunnel.
4 5 6 |
# File 'lib/pair/session/tunnel.rb', line 4 def tunnel @tunnel end |
Instance Method Details
#close ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/pair/session/tunnel.rb', line 34 def close @tunnel_closed ||= begin puts "Closing connection..." Process.kill("INT", tunnel.pid) Process.wait true end end |
#open ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/pair/session/tunnel.rb', line 24 def open self.tunnel = IO.popen(ssh_command) puts "SSH tunnel started (PID = #{tunnel.pid})" if $-d if block_given? yield close end end |