websocket

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewWsConn

func NewWsConn(conn *websocket.Conn) *wsConn

Types

type Config

type Config struct {
	UserName      string
	IpAddress     string //IP地址
	Port          string
	Password      string // 密码连接
	PrivateKey    string // 私钥连接
	KeyPassphrase string // 私钥密码
	Width         int    // pty width
	Height        int    // pty height
}

type Meta

type Meta struct {
	TERM      string
	Width     int
	Height    int
	UserName  string
	ConnectId string
	HostId    uint
	HostName  string
}

type RecordData

type RecordData struct {
	Event string  `json:"event"` // 输入输出事件
	Time  float64 `json:"time"`  // 时间差
	Data  []byte  `json:"data"`  // 数据
}

type Terminal

type Terminal struct {
	Client *ssh.Client
	TERM   string
	// contains filtered or unexported fields
}

func NewTerminal

func NewTerminal(config Config) (*Terminal, error)

func (*Terminal) Close

func (t *Terminal) Close() (err error)

func (*Terminal) Connect

func (t *Terminal) Connect(stdin io.Reader, stdout io.Writer, stderr io.Writer) error

func (*Terminal) IsClosed

func (t *Terminal) IsClosed() bool

IsClosed 终端是否已关闭

func (*Terminal) SetCloseHandler

func (t *Terminal) SetCloseHandler(h func() error)

func (*Terminal) SetWinSize

func (t *Terminal) SetWinSize(h int, w int)

type WebSocketStream

type WebSocketStream struct {
	sync.RWMutex
	Terminal *Terminal // ssh客户端
	Conn     *wsConn   // socket 连接

	CreatedAt models.LocalTime // 创建时间
	UpdatedAt models.LocalTime // 最新的更新时间
	Meta      Meta             // 元信息
	// contains filtered or unexported fields
}

func NewWebSocketSteam

func NewWebSocketSteam(terminal *Terminal, connection *wsConn, meta Meta) *WebSocketStream

NewWebSocketSteam 创建websocket数据流

func (*WebSocketStream) Read

func (r *WebSocketStream) Read(p []byte) (n int, err error)

func (*WebSocketStream) Write

func (r *WebSocketStream) Write(p []byte) (n int, err error)

func (*WebSocketStream) Write2Log

func (r *WebSocketStream) Write2Log() error

Jump to

Keyboard shortcuts

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