Documentation
¶
Index ¶
- type AuthMethod
- type Device
- type Option
- type SSHConnection
- func (c *SSHConnection) Device() *Device
- func (c *SSHConnection) GetLastUsed() time.Time
- func (c *SSHConnection) Host() string
- func (c *SSHConnection) IsConnected() bool
- func (c *SSHConnection) RunCommand(cmd string) ([]byte, error)
- func (c *SSHConnection) Start(expiredConnectionTimeout time.Duration) error
- func (c *SSHConnection) Stop(err error)
- type SSHConnectionManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthMethod ¶
type AuthMethod func(*ssh.ClientConfig)
AuthMethod is the method to use to authenticate agaist the device
func AuthByPassword ¶
func AuthByPassword(username, password string) AuthMethod
AuthByPassword uses password authentication
type Device ¶
type Device struct {
Host string
Auth AuthMethod
}
Device is the basic configuration needed to connect to the device
type Option ¶
type Option func(*SSHConnectionManager)
Option defines options for the manager which are applied on creation
func WithExpiredConnectionTimeout ¶
WithExpiredConnectionTime sets the timeout after an unused ssh connection will not be keepalived
func WithKeepAliveInterval ¶
WithKeepAliveInterval sets the keep alive interval (default 10 seconds)
func WithKeepAliveTimeout ¶
WithKeepAliveTimeout sets the timeout after an ssh connection to be determined dead (default 15 seconds)
func WithReconnectInterval ¶
WithReconnectInterval sets the reconnect interval (default 10 seconds)
type SSHConnection ¶
type SSHConnection struct {
// contains filtered or unexported fields
}
SSHConnection encapsulates the connection to the device
func NewSSHConnection ¶
func (*SSHConnection) Device ¶
func (c *SSHConnection) Device() *Device
Device returns the device information of the connected device
func (*SSHConnection) GetLastUsed ¶
func (c *SSHConnection) GetLastUsed() time.Time
func (*SSHConnection) Host ¶
func (c *SSHConnection) Host() string
Host returns the hostname of the connected device
func (*SSHConnection) IsConnected ¶
func (c *SSHConnection) IsConnected() bool
func (*SSHConnection) RunCommand ¶
func (c *SSHConnection) RunCommand(cmd string) ([]byte, error)
RunCommand runs a command against the device
func (*SSHConnection) Start ¶
func (c *SSHConnection) Start(expiredConnectionTimeout time.Duration) error
func (*SSHConnection) Stop ¶
func (c *SSHConnection) Stop(err error)
type SSHConnectionManager ¶
type SSHConnectionManager struct {
// contains filtered or unexported fields
}
SSHConnectionManager manages SSH connections to different devices
func NewConnectionManager ¶
func NewConnectionManager(opts ...Option) *SSHConnectionManager
NewConnectionManager creates a new connection manager
func (*SSHConnectionManager) CloseAll ¶
func (m *SSHConnectionManager) CloseAll() error
CloseAll closes all TCP connections and stops keep alives
func (*SSHConnectionManager) GetSSHConnection ¶
func (m *SSHConnectionManager) GetSSHConnection(device *Device) (*SSHConnection, error)
GetSSHConnection gets a cached SSHConnection or creates a fresh one, if necessary