telnet

package
v0.0.0-...-fa7ff3c Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CR = byte('\r')
	LF = byte('\n')
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(cfg *ClientConfig) (*Client, error)

func (*Client) Close

func (this *Client) Close() error

func (*Client) FirstPrompt

func (this *Client) FirstPrompt() string

FirstPrompt 获取登录后(跳过用户名、密码提示符)的第一个提示符

func (*Client) LocalAddr

func (this *Client) LocalAddr() net.Addr

func (*Client) Read

func (this *Client) Read(buf []byte) (int, error)

Read is for implement an io.Reader interface

func (*Client) ReadByte

func (this *Client) ReadByte() (byte, error)

func (*Client) ReadRune

func (this *Client) ReadRune() (r rune, size int, err error)

func (*Client) ReadUtil

func (this *Client) ReadUtil(delim byte) (bytes.Buffer, error)

func (*Client) ReadUtil2

func (this *Client) ReadUtil2(delims ...string) (bytes.Buffer, int, error)

ReadUtil2 读取数据直到遇到指定的分隔符之一,返回读取的数据和对应分隔符的索引

func (*Client) RemoteAddr

func (this *Client) RemoteAddr() net.Addr

func (*Client) ScrollToNewLine

func (this *Client) ScrollToNewLine() error

ScrollToNewLine 滚动到新的一行

func (*Client) SetDeadline

func (this *Client) SetDeadline(t time.Time) error

func (*Client) SetEcho

func (this *Client) SetEcho(echo bool) error

func (*Client) SetReadDeadline

func (this *Client) SetReadDeadline(t time.Time) error

func (*Client) SetSuppressGA

func (this *Client) SetSuppressGA(suppressGA bool) error

func (*Client) SetWriteDeadline

func (this *Client) SetWriteDeadline(t time.Time) error

func (*Client) SkipUtil

func (this *Client) SkipUtil(delim byte) error

func (*Client) SkipUtil2

func (this *Client) SkipUtil2(delims ...string) (int, error)

SkipUtil2 忽略数据直到遇到指定的分隔符之一,返回对应分隔符的索引

func (*Client) Welcome

func (this *Client) Welcome() string

func (*Client) Write

func (this *Client) Write(buf []byte) (n int, err error)

Write is for implements an io.Writer interface.

type ClientConfig

type ClientConfig struct {
	Addr          string
	User          string
	Password      string
	UserRegex     *regexp.Regexp // 匹配用户名提示符的正则
	PassRegex     *regexp.Regexp // 匹配密码提示符的正则
	PromptRegex   *regexp.Regexp // 匹配提示符的正则
	Timeout       time.Duration  // 连接超时时间, 默认15秒
	WriteTimeout  time.Duration  // 写超时时间, 默认5秒
	UnixWriteMode bool           // 如果设置,Write 将任何 '\n' (LF) 转换为 '\r\n' (CR LF)
	Echo          bool           // 如果设置,将允许回显(取决于服务端是否支持),部分网络设备上无效(总是回显)
	SuppressGA    bool           // 如果设置,将抑制 "go ahead" 命令
	TLS           *tls.Config
}

Jump to

Keyboard shortcuts

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