Class: Tunneler::SshTunnel::Gateway
- Inherits:
-
Net::SSH::Gateway
- Object
- Net::SSH::Gateway
- Tunneler::SshTunnel::Gateway
- Defined in:
- lib/tunneler/ssh_tunnel.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(host, user, options = {}) ⇒ Gateway
constructor
A new instance of Gateway.
- #reconnect ⇒ Object
Constructor Details
#initialize(host, user, options = {}) ⇒ Gateway
Returns a new instance of Gateway.
28 29 30 31 32 33 |
# File 'lib/tunneler/ssh_tunnel.rb', line 28 def initialize(host, user, ={}) super @host = host @user = user @options = end |
Class Method Details
.connect(host, user, options = {}) ⇒ Object
35 36 37 38 39 |
# File 'lib/tunneler/ssh_tunnel.rb', line 35 def self.connect(host, user, ={}) gateway = self.new(host, user, ) gateway.open("127.0.0.1", self.random_open_port) gateway end |
.random_open_port ⇒ Object
41 42 43 44 45 |
# File 'lib/tunneler/ssh_tunnel.rb', line 41 def self.random_open_port socket = Socket.new(:INET, :STREAM, 0) socket.bind(Addrinfo.tcp("127.0.0.1", 0)) socket.local_address.ip_port end |
Instance Method Details
#reconnect ⇒ Object
47 48 49 50 |
# File 'lib/tunneler/ssh_tunnel.rb', line 47 def reconnect shutdown! self.class.connect(@host,@user,@options) end |