class Tunneler::SshTunnel::Gateway

Public Class Methods

connect(host, user, options={}) click to toggle source
# File lib/tunneler/ssh_tunnel.rb, line 35
def self.connect(host, user, options={})
  gateway = self.new(host, user, options)
  gateway.open("127.0.0.1", self.random_open_port)
  gateway
end
new(host, user, options={}) click to toggle source
Calls superclass method
# File lib/tunneler/ssh_tunnel.rb, line 28
def initialize(host, user, options={})
  super
  @host = host
  @user = user
  @options = options
end
random_open_port() click to toggle source
# 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

Public Instance Methods

reconnect() click to toggle source
# File lib/tunneler/ssh_tunnel.rb, line 47
def reconnect
  shutdown!
  self.class.connect(@host,@user,@options)
end