host

package
v0.0.0-...-5d74809 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MsgData   = '1'
	MsgResize = '2'
)

Turn

Variables

This section is empty.

Functions

func AddHostHandler

func AddHostHandler(svcCtx *svc.ServiceContext) http.HandlerFunc

func EditHostHandler

func EditHostHandler(svcCtx *svc.ServiceContext) http.HandlerFunc

func HostsHandler

func HostsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc

func NewSSHClient

func NewSSHClient(conf *SSHClientConfig) (*ssh.Client, error)

func WsHandler

func WsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc

Types

type AuthModel

type AuthModel int8

ssh config

const (
	PASSWORD AuthModel = iota + 1
	PUBLICKEY
)

type RecHeader

type RecHeader struct {
	Version   int   `json:"version"`
	Width     int   `json:"width"`
	Height    int   `json:"height"`
	Timestamp int64 `json:"timestamp"`
	Env       struct {
		Shell string `json:"SHELL"`
		Term  string `json:"TERM"`
	} `json:"env"`
}

type RecType

type RecType string

recorder

const (
	InputType  RecType = "i"
	OutPutType RecType = "o"
)

type Recorder

type Recorder struct {
	StartTime time.Time
	Writer    io.Writer
	sync.Mutex
}

func NewRecorder

func NewRecorder(writer io.Writer) *Recorder

func (*Recorder) WriteData

func (rec *Recorder) WriteData(rectype RecType, data string)

func (*Recorder) WriteHeader

func (rec *Recorder) WriteHeader(height, width int)

type Resize

type Resize struct {
	Columns int
	Rows    int
}

type SSHClientConfig

type SSHClientConfig struct {
	AuthModel AuthModel
	HostAddr  string
	User      string
	Password  string
	KeyPath   string
	Timeout   time.Duration
}

func SSHClientConfigPassword

func SSHClientConfigPassword(hostAddr, user, Password string) *SSHClientConfig

func SSHClientConfigPulicKey

func SSHClientConfigPulicKey(hostAddr, user, keyPath string) *SSHClientConfig

type Turn

type Turn struct {
	StdinPipe io.WriteCloser
	Session   *ssh.Session
	WsConn    *websocket.Conn
	Recorder  *Recorder
}

func NewTurn

func NewTurn(wsConn *websocket.Conn, sshClient *ssh.Client, rec *Recorder) (*Turn, error)

func (*Turn) Close

func (t *Turn) Close() error

func (*Turn) LoopRead

func (t *Turn) LoopRead(logBuff *bytes.Buffer, context context.Context) error

func (*Turn) Read

func (t *Turn) Read(p []byte) (n int, err error)

func (*Turn) SessionWait

func (t *Turn) SessionWait() error

func (*Turn) Write

func (t *Turn) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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