Documentation ¶
Index ¶
- Constants
- Variables
- func NewConnection(cfg *connection.Config, logger hclog.Logger) connection.Connection
- type Telnet
- func (tn *Telnet) Close() error
- func (tn *Telnet) Closed() chan bool
- func (tn *Telnet) Exit()
- func (tn *Telnet) Expect(ctx context.Context, r *connection.Request) *connection.Response
- func (tn *Telnet) GetConfig() *connection.Config
- func (tn *Telnet) GetHost() string
- func (tn *Telnet) GetRegexPrompt() string
- func (tn *Telnet) Go(delims ...string) ([]byte, error)
- func (tn *Telnet) Heartbeat() connection.Heartbeat
- func (tn *Telnet) Init() error
- func (tn *Telnet) LastUsed() (bool, time.Time)
- func (tn *Telnet) Login() error
- func (tn *Telnet) NewRequest(cmd string, expect []string, errors []string) *connection.Request
- func (tn *Telnet) Ping() error
- func (tn *Telnet) Renewed() chan uint
- func (tn *Telnet) Sendln(s string) error
- func (tn *Telnet) SetHost(host string)
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) Expect ¶
func (tn *Telnet) Expect(ctx context.Context, r *connection.Request) *connection.Response
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) GetRegexPrompt ¶
func (*Telnet) Heartbeat ¶
func (tn *Telnet) Heartbeat() connection.Heartbeat
func (*Telnet) Init ¶
initialize the telnet struct connects to the tcp-socket and starts the handle()
func (*Telnet) NewRequest ¶
Create new request
Click to show internal directories.
Click to hide internal directories.