websocket

package
v0.7.6 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventCancel  = "cancel"
	EventConnect = "connect"
)
View Source
const (
	WSStatusSuccess = "0"
	WSStatusError   = "-1"

	DefaultStatusInterval = 2 * time.Second
)

Variables

View Source
var (
	DefaultSSHCMDTimeout = time.Duration(utils.GetEnvInt("ENV_SSH_CMD_TIMEOUT", defaultSSHCMDTimeout)) * time.Second
)

Functions

This section is empty.

Types

type HostStatusRequest

type HostStatusRequest struct {
	Request
	Interval int `json:"interval"`
}

type Request

type Request struct {
	Type  string `json:"type"`
	Id    int    `json:"id"`
	Cmd   string `json:"cmd"`
	CType string `json:"cmd_type"`
	CmdId int    `json:"cmd_id"`
}

type SSHSession

type SSHSession struct {
	*transport.Session
	// contains filtered or unexported fields
}

SSHSession connect to ssh server using ssh session.

func NewSshConn

func NewSshConn(cols, rows int, sshClient *transport.Client) (*SSHSession, error)

func (*SSHSession) Close

func (s *SSHSession) Close()

func (*SSHSession) ReceiveWsMsg

func (s *SSHSession) ReceiveWsMsg(wsConn *websocket.Conn, exitCh chan struct{})

ReceiveWsMsg receive websocket msg do some handling then write into ssh.session.stdin

func (*SSHSession) SendComboOutput

func (s *SSHSession) SendComboOutput(wsConn *websocket.Conn, exitCh chan struct{})

func (*SSHSession) SessionWait

func (s *SSHSession) SessionWait(quitChan chan struct{})

type VNCForward

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

func NewVNCForward

func NewVNCForward(wsConn *websocket.Conn, tcpConn net.Conn, logger *logger.Logger, quitChan chan struct{}) *VNCForward

func (*VNCForward) Close

func (vf *VNCForward) Close()

func (*VNCForward) Serve

func (vf *VNCForward) Serve()

type WSConnect

type WSConnect struct {
	*websocket.Conn
	// contains filtered or unexported fields
}

func NewWSConnect

func NewWSConnect(conn *websocket.Conn, engine WebService) *WSConnect

func (*WSConnect) Close

func (w *WSConnect) Close() error

func (*WSConnect) HandlerFTaskStatus

func (w *WSConnect) HandlerFTaskStatus(conn *websocket.Conn, msg *WsMsg)

func (*WSConnect) HandlerHostStatus

func (w *WSConnect) HandlerHostStatus(conn *websocket.Conn, msg *WsMsg)

func (*WSConnect) HandlerResize

func (w *WSConnect) HandlerResize(conn *websocket.Conn, msg *WsMsg)

func (*WSConnect) HandlerSSHShell

func (w *WSConnect) HandlerSSHShell(conn *websocket.Conn, msg *WsMsg)

func (*WSConnect) InitHandlers

func (w *WSConnect) InitHandlers() *WSConnect

func (*WSConnect) Serve

func (w *WSConnect) Serve()

func (*WSConnect) WriteMsg

func (w *WSConnect) WriteMsg(msg interface{})

type WebService

type WebService interface {
	RunCmdWithContext(host *models.Host, cmd ssh.Command, ch chan *ssh.Result)
	GetSSHManager() *ssh.Manager
}

type WsHandler

type WsHandler func(conn *websocket.Conn, msg *WsMsg)

type WsMsg

type WsMsg struct {
	Type  string      `json:"type"`
	Data  interface{} `json:"data"`
	Event string      `json:"event"`
	Body  []byte      `json:"-"`
}

Jump to

Keyboard shortcuts

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