connection

package
v0.0.0-...-fc64511 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2020 License: MIT, MIT Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RemoveHostChan = make(chan string, 100)

Channel to send remove host to. When received the host is removed from the cache

Functions

This section is empty.

Types

type Config

type Config struct {
	Type          Type          `json:"type" hcl:",label"`
	User          string        `json:"username" hcl:"username"`
	Password      string        `json:"password" hcl:"password"`
	Port          int           `json:"port" hcl:"port"`
	ScreenLength  string        `json:"screen_length" hcl:"screen_length,optional"`
	RegexPrompt   string        `json:"default_prompt" hcl:"default_prompt"`
	Errors        string        `json:"default_errors" hcl:"default_errors"`
	CacheTTL      time.Duration `json:"cache_ttl" hcl:"cache_ttl,optional"`
	ReadDeadLine  time.Duration `json:"read_dead_line" hcl:"read_dead_line,optional"`
	WriteDeadLine time.Duration `json:"write_dead_line" hcl:"write_dead_line,optional"`
	SSHKeyPath    string        `json:"ssh_key_path" hcl:"ssh_key_path,optional"`
}

Connection specific configuration.

type Connection

type Connection interface {
	Init() error
	Exit()

	GetConfig() *Config
	Close() error
	GetHost() string
	SetHost(host string)
	Heartbeat() Heartbeat

	Lock()
	Unlock()

	Closed() chan bool
	Renewed() chan uint

	LastUsed() (bool, time.Time)

	Ping() error
	Login() error

	NewRequest(cmd string, expect []string, errors []string) *Request
	Expect(ctx context.Context, req *Request) *Response

	GetRegexPrompt() string
}

type Heartbeat

type Heartbeat struct {
	Recv chan int
	Send chan int
}

func (Heartbeat) IsAlive

func (hb Heartbeat) IsAlive() bool

check if handle() is alive

type Request

type Request struct {
	Send   string        // command
	Expect []string      // expected return
	Errors []string      // catch errors
	TTL    time.Duration // time to wait for command to finish.

	// channel to receive Responses on
	Responses chan Response
}

request sent to the handle()

type Response

type Response struct {
	Data string
	Err  error
}

Response from commands

type Type

type Type string
const (
	Telnet Type = "telnet"
	SSH    Type = "ssh"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL