Class: Crudboy::SSHProxy

Inherits:
Object show all
Defined in:
lib/crudboy/ssh_proxy.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configObject

Returns the value of attribute config.



8
9
10
# File 'lib/crudboy/ssh_proxy.rb', line 8

def config
  @config
end

.local_ssh_proxy_portObject

Returns the value of attribute local_ssh_proxy_port.



8
9
10
# File 'lib/crudboy/ssh_proxy.rb', line 8

def local_ssh_proxy_port
  @local_ssh_proxy_port
end

.ssh_gatewayObject

Returns the value of attribute ssh_gateway.



8
9
10
# File 'lib/crudboy/ssh_proxy.rb', line 8

def ssh_gateway
  @ssh_gateway
end

Class Method Details

.active?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/crudboy/ssh_proxy.rb', line 26

def active?
  @ssh_gateway.active?
end

.connect(config) ⇒ Object



10
11
12
13
14
# File 'lib/crudboy/ssh_proxy.rb', line 10

def connect(config)
  @config = config
  @ssh_gateway = Net::SSH::Gateway.new(config[:host], config[:user], config.slice(:port, :password).symbolize_keys.merge(keepalive: true, keepalive_interval: 30, loop_wait: 1))
  @local_ssh_proxy_port = @ssh_gateway.open(config[:forward_host], config[:forward_port], config[:local_port])
end

.reconnectObject



16
17
18
# File 'lib/crudboy/ssh_proxy.rb', line 16

def reconnect
  reconnect! unless @ssh_gateway.active?
end

.reconnect!Object



20
21
22
23
24
# File 'lib/crudboy/ssh_proxy.rb', line 20

def reconnect!
  @ssh_gateway.shutdown!
  @ssh_gateway = Net::SSH::Gateway.new(@config[:host], @config[:user], @config.slice(:port, :password).symbolize_keys)
  @ssh_gateway.open(config[:forward_host], config[:forward_port], @local_ssh_proxy_port)
end