telnet

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: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (

	// new lines in bytes.
	CR          = byte('\r')
	LF          = byte('\n')
	CRLF string = "\r\n"
)

connection constants

View Source
const (
	LFCF                 = "\r\n"
	DefaultRegexPrompt   = "\\n[<\\[](\\S+)[>#\\]]$"
	DefaultTtl           = time.Second * 30
	DefaultReadDeadline  = time.Second * 5
	DefaultWriteDeadline = time.Second * 3
	DefaultPort          = 23
	DefaultError         = "error|failed|unrecognized"
)

telnet cache const

Variables

View Source
var (
	ErrExpectDeadline = fmt.Errorf("expect reached a deadline timeout")
)

Functions

func NewConnection

func NewConnection(cfg *connection.Config, logger hclog.Logger) connection.Connection

Create a new telnet

Types

type Telnet

type Telnet struct {
	*connection.Config
	ConnectionClosedChan  chan bool
	ConnectionRenewedChan chan uint

	// Mutex to lock down last used and initialized
	*sync.Mutex
	// contains filtered or unexported fields
}

The telnet struct that holds the connection. is an item in the connection. map[string]Telnet

func (*Telnet) Close

func (tn *Telnet) Close() error

func (*Telnet) Closed

func (tn *Telnet) Closed() chan bool

func (*Telnet) Exit

func (tn *Telnet) Exit()

exit the handle() and kill connection.

func (*Telnet) Expect

Passes a request to the handler and waits for the response on the channel created

func (*Telnet) GetConfig

func (tn *Telnet) GetConfig() *connection.Config

func (*Telnet) GetHost

func (tn *Telnet) GetHost() string

func (*Telnet) GetRegexPrompt

func (tn *Telnet) GetRegexPrompt() string

func (*Telnet) Go

func (tn *Telnet) Go(delims ...string) ([]byte, error)

func (*Telnet) Heartbeat

func (tn *Telnet) Heartbeat() connection.Heartbeat

func (*Telnet) Init

func (tn *Telnet) Init() error

initialize the telnet struct connects to the tcp-socket and starts the handle()

func (*Telnet) LastUsed

func (tn *Telnet) LastUsed() (bool, time.Time)

func (*Telnet) Login

func (tn *Telnet) Login() error

func (*Telnet) NewRequest

func (tn *Telnet) NewRequest(cmd string, expect []string, errors []string) *connection.Request

Create new request

func (*Telnet) Ping

func (tn *Telnet) Ping() error

Exported function to check if the connection is alive.

func (*Telnet) Renewed

func (tn *Telnet) Renewed() chan uint

func (*Telnet) Sendln

func (tn *Telnet) Sendln(s string) error

func (*Telnet) SetHost

func (tn *Telnet) SetHost(host string)

Jump to

Keyboard shortcuts

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