Class: Wemux::Pair::SshTunnel
- Inherits:
-
Object
- Object
- Wemux::Pair::SshTunnel
- Defined in:
- lib/wemux/pair/ssh_tunnel.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#port_offset ⇒ Object
readonly
Returns the value of attribute port_offset.
Class Method Summary collapse
Instance Method Summary collapse
- #client_port ⇒ Object
- #close_tunnels ⇒ Object
- #host_port ⇒ Object
-
#initialize(port_offset) ⇒ SshTunnel
constructor
A new instance of SshTunnel.
- #open ⇒ Object
- #ssh_options ⇒ Object
Constructor Details
#initialize(port_offset) ⇒ SshTunnel
Returns a new instance of SshTunnel.
8 9 10 |
# File 'lib/wemux/pair/ssh_tunnel.rb', line 8 def initialize(port_offset) @port_offset = port_offset end |
Instance Attribute Details
#port_offset ⇒ Object (readonly)
Returns the value of attribute port_offset.
6 7 8 |
# File 'lib/wemux/pair/ssh_tunnel.rb', line 6 def port_offset @port_offset end |
Class Method Details
.tunnel_failure! ⇒ Object
12 13 14 15 |
# File 'lib/wemux/pair/ssh_tunnel.rb', line 12 def self.tunnel_failure! puts "The tunnel failed to open, the port was probably in use, try again." exit 1 end |
Instance Method Details
#client_port ⇒ Object
21 22 23 |
# File 'lib/wemux/pair/ssh_tunnel.rb', line 21 def client_port 9990 + port_offset end |
#close_tunnels ⇒ Object
40 41 42 43 |
# File 'lib/wemux/pair/ssh_tunnel.rb', line 40 def close_tunnels puts "Closing existing tunnels..." system "ssh #{} -O exit #{ssh_user}@#{ssh_host}" until $? && !$?.success? end |
#host_port ⇒ Object
17 18 19 |
# File 'lib/wemux/pair/ssh_tunnel.rb', line 17 def host_port 1230 + port_offset end |
#open ⇒ Object
25 26 27 28 29 |
# File 'lib/wemux/pair/ssh_tunnel.rb', line 25 def open close_tunnels puts "Opening tunnel..." system "ssh #{} -f -N #{ssh_forwards} #{ssh_user}@#{ssh_host}" end |
#ssh_options ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/wemux/pair/ssh_tunnel.rb', line 31 def [ "ExitOnForwardFailure yes", "ControlPersist yes", "ControlPath #{control_path}", "ControlMaster auto", ].map { |o| "-o \"#{o}\""}.join(" ") end |