Documentation ¶
Index ¶
- Constants
- Variables
- func GbkToUtf8(s []byte) ([]byte, error)
- type Client
- type PromptType
- type Session
- func JumpDial(...) (*Session, error)
- func SerialOpen(comName string, baudrate, dataBits, stopBits int, parity string, ...) (*Session, error)
- func SshDial(addr, username, password string, timeout time.Duration) (*Session, error)
- func TelnetDial(addr, username, password string, timeout time.Duration) (*Session, error)
- func (s *Session) Close() error
- func (s *Session) Cmd(cmd string, timeout time.Duration, isFindPromptFirst ...bool) (reply string, err error)
- func (s *Session) Enable(password string, timeout ...time.Duration) error
- func (s *Session) Exec(cmd string, timeout time.Duration) (reply string, err error)
- func (s *Session) GetReply(time time.Duration) (string, error)
- func (s *Session) IOHandle(w io.Writer, r, e io.Reader)
- func (s *Session) IsSessionOK() (isOk bool)
- func (s *Session) SetHostname(hostname string)
- func (s *Session) SetMoreStr(key, moreStr string)
- func (s *Session) SetPrompt(key, promptStr string)
- func (s *Session) Wait()
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 ¶
Types ¶
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 TelnetDial ¶
func (*Session) IsSessionOK ¶
func (*Session) SetHostname ¶
func (*Session) SetMoreStr ¶
Click to show internal directories.
Click to hide internal directories.