consoleChan

package module
v0.0.0-...-f39870e Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PromptStd = iota
	PromptEnable
	PromptPassword
	PromptLogin
	PromptUnknow
)
View Source
const (
	MORE_STRING = "-MORE-"
	More_STRING = "-More-"
)
View Source
const (
	LoginKey    = "login"
	PasswordKey = "pwd"
	EnableKey   = "enable"
	StandKey    = "std"
)
View Source
const (
	CR = "\r\n"
)
View Source
const (
	JumpDone = "done"
)

Variables

View Source
var (
	ErrNeedPassword = errors.New("Need to input password")
	ErrTimeout      = errors.New("timeout")
)
View Source
var PromptWait = 200 * time.Millisecond

Functions

func GbkToUtf8

func GbkToUtf8(s []byte) ([]byte, error)

Types

type Client

type Client interface {
	Dial() (Session, error)
}

type PromptType

type PromptType int

type Session

type Session struct {
	Stderr <-chan string
	// contains filtered or unexported fields
}

func JumpDial

func JumpDial(sshCmd, sshDone, telnetCmd, telnetDone, jumpHostAddr, jumpHostUsername, jumpHostPassword, jumpType, targetAddr, targetUsername, targetPassword, targetType string, timeout time.Duration) (*Session, error)

JumpDial for connect to and login target addr through jump host. Jump host to target just only use telnet protocol jumpType only "ssh" or "telnet"

func SerialOpen

func SerialOpen(comName string, baudrate, dataBits, stopBits int, parity string, username, password string, timeout time.Duration) (*Session, error)

func SshDial

func SshDial(addr, username, password string, timeout time.Duration) (*Session, error)

func TelnetDial

func TelnetDial(addr, username, password string, timeout time.Duration) (*Session, error)

func (*Session) Close

func (s *Session) Close() error

func (*Session) Cmd

func (s *Session) Cmd(cmd string, timeout time.Duration, isFindPromptFirst ...bool) (reply string, err error)

func (*Session) Enable

func (s *Session) Enable(password string, timeout ...time.Duration) error

func (*Session) Exec

func (s *Session) Exec(cmd string, timeout time.Duration) (reply string, err error)

func (*Session) GetReply

func (s *Session) GetReply(time time.Duration) (string, error)

func (*Session) IOHandle

func (s *Session) IOHandle(w io.Writer, r, e io.Reader)

func (*Session) IsSessionOK

func (s *Session) IsSessionOK() (isOk bool)

func (*Session) SetHostname

func (s *Session) SetHostname(hostname string)

func (*Session) SetMoreStr

func (s *Session) SetMoreStr(key, moreStr string)

func (*Session) SetPrompt

func (s *Session) SetPrompt(key, promptStr string)

func (*Session) Wait

func (s *Session) Wait()

Jump to

Keyboard shortcuts

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