Version: v0.0.1 Latest Latest

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

Go to latest
Published: Aug 1, 2019 License: MIT Imports: 16 Imported by: 0




This section is empty.


This section is empty.


func NewSshClient

func NewSshClient() (*ssh.Client, error)

func WsSsh

func WsSsh(c *gin.Context)

handle webSocket connection. first,we establish a ssh connection to ssh server when a webSocket comes; then we deliver ssh data via ssh connection between browser and ssh server. That is, read webSocket data from browser (e.g. 'ls' command) and send data to ssh server via ssh connection; the other hand, read returned ssh data from ssh server and write back to browser via webSocket API.


type SshConn

type SshConn struct {
	// calling Write() to write data into ssh server
	StdinPipe io.WriteCloser
	// Write() be called to receive data from ssh server
	ComboOutput *wsBufferWriter
	Session     *ssh.Session

connect to ssh server using ssh session.

func NewSshConn

func NewSshConn(cols, rows int, sshClient *ssh.Client) (*SshConn, error)

setup ssh shell session set Session and StdinPipe here, and the Session.Stdout and Session.Sdterr are also set.

func (*SshConn) Close

func (s *SshConn) Close()

func (*SshConn) ReceiveWsMsg

func (ssConn *SshConn) ReceiveWsMsg(wsConn *websocket.Conn, logBuff *bytes.Buffer, exitCh chan bool)

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

func (*SshConn) SendComboOutput

func (ssConn *SshConn) SendComboOutput(wsConn *websocket.Conn, exitCh chan bool)

func (*SshConn) SessionWait

func (ssConn *SshConn) SessionWait(quitChan chan bool)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL