Class: SSHKit::EC2InstanceConnect::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/sshkit/ec2instanceconnect.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



19
20
21
22
23
24
25
# File 'lib/sshkit/ec2instanceconnect.rb', line 19

def initialize
  @logger = ::Logger.new(IO::NULL)
  @ssh_key_refresh_enabled = true
  @ssh_key_size = 3072
  @tunnel_enabled = false
  @tunnel_ports = 8000...8100
end

Instance Attribute Details

#loggerObject

Returns the value of attribute logger.



17
18
19
# File 'lib/sshkit/ec2instanceconnect.rb', line 17

def logger
  @logger
end

#ssh_key_refresh_enabledObject

Returns the value of attribute ssh_key_refresh_enabled.



17
18
19
# File 'lib/sshkit/ec2instanceconnect.rb', line 17

def ssh_key_refresh_enabled
  @ssh_key_refresh_enabled
end

#ssh_key_sizeObject

Returns the value of attribute ssh_key_size.



17
18
19
# File 'lib/sshkit/ec2instanceconnect.rb', line 17

def ssh_key_size
  @ssh_key_size
end

#tunnel_enabledObject

Returns the value of attribute tunnel_enabled.



17
18
19
# File 'lib/sshkit/ec2instanceconnect.rb', line 17

def tunnel_enabled
  @tunnel_enabled
end

#tunnel_portsObject

Returns the value of attribute tunnel_ports.



17
18
19
# File 'lib/sshkit/ec2instanceconnect.rb', line 17

def tunnel_ports
  @tunnel_ports
end

Instance Method Details

#random_tunnel_portObject

Returns a secure random tunnel port.



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/sshkit/ec2instanceconnect.rb', line 28

def random_tunnel_port
  random_number = SecureRandom.random_number(tunnel_ports.size)

  case tunnel_ports
  when Array
    tunnel_ports[random_number]
  when Range
    tunnel_ports.begin + random_number
  else
    raise ArgumentError, 'tunnel_ports must be an Array or Range'
  end
end