shell

package
Version: v1.0.31 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2021 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CmdError 錯誤
	CmdError = iota + 1
	// CmdResize 更改窗口大小
	CmdResize
	// CmdInfo 返回終端信息
	CmdInfo
	// CmdHeart websocket 心跳防止瀏覽器 關閉不獲取 websocket
	CmdHeart
	// CmdFontSize 設置字體大小
	CmdFontSize
	// CmdFontFamily 設置字體
	CmdFontFamily
)

Variables

View Source
var ErrAlreadyAttach = errors.New(`shell already attach websocket`)

ErrAlreadyAttach .

View Source
var ErrShellidDuplicate = errors.New(`new shell id duplicate`)

ErrShellidDuplicate .

View Source
var ErrShellidNotExists = errors.New(`shell id not exists`)

ErrShellidNotExists .

View Source
var ErrUsernameNotExists = errors.New(`shell username not exists`)

ErrUsernameNotExists .

Functions

func WriteInfo

func WriteInfo(ws *websocket.Conn, id int64, name string, started int64, fontSize int, fontFamily string) (e error)

WriteInfo .

Types

type Element

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

Element .

func (*Element) Attach

func (element *Element) Attach(ws *websocket.Conn, username string, shellid int64, cols, rows uint16, newshell bool) (s *Shell, e error)

Attach .

func (*Element) Kill

func (element *Element) Kill(username string, shellid int64) (e error)

Kill .

func (*Element) Rename

func (element *Element) Rename(username string, shellid int64, name string) (e error)

Rename .

func (*Element) Unattach

func (element *Element) Unattach(username string, shellid int64) (ok bool)

Unattach .

type ListInfo

type ListInfo struct {
	// shell id
	ID int64 `json:"id,omitempty"`
	// shell 顯示名稱
	Name string `json:"name,omitempty"`
	// 是否 附加 websocket
	Attached bool `json:"attached,omitempty"`
}

ListInfo .

type Manager

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

Manager .

func Single

func Single() *Manager

Single .

func (*Manager) Attach

func (m *Manager) Attach(ws *websocket.Conn, username string, shellid int64, cols, rows uint16, newshell bool) (s *Shell, e error)

Attach .

func (*Manager) Kill

func (m *Manager) Kill(username string, shellid int64) (e error)

Kill .

func (*Manager) List

func (m *Manager) List(username string) (arrs []ListInfo)

List 列举 shell 状态

func (*Manager) Rename

func (m *Manager) Rename(username string, shellid int64, name string) (e error)

Rename .

func (*Manager) Restore

func (m *Manager) Restore()

Restore 恢复 shell

func (*Manager) Unattach

func (m *Manager) Unattach(username string, shellid int64) (e error)

Unattach 進程結束 釋放資源

type Message

type Message struct {
	Cmd  int    `json:"cmd,omitempty"`
	Cols uint16 `json:"cols,omitempty"`
	Rows uint16 `json:"rows,omitempty"`
	Val  int    `json:"val,omitempty"`
	Str  string `json:"str,omitempty"`
}

Message .

func (*Message) Unmarshal

func (m *Message) Unmarshal(data []byte) error

Unmarshal .

type Shell

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

Shell .

func (*Shell) Attack

func (s *Shell) Attack(ws *websocket.Conn, cols, rows uint16) (e error)

Attack .

func (*Shell) IsAttack

func (s *Shell) IsAttack() (yes bool)

IsAttack .

func (*Shell) Kill

func (s *Shell) Kill()

Kill 關閉 進程

func (*Shell) Rename

func (s *Shell) Rename(name string)

Rename .

func (*Shell) Run

func (s *Shell) Run(ws *websocket.Conn, cols, rows uint16) (e error)

Run 运行 shell

func (*Shell) SetFontFamily

func (s *Shell) SetFontFamily(val string) (e error)

SetFontFamily .

func (*Shell) SetFontSize

func (s *Shell) SetFontSize(val int) (e error)

SetFontSize .

func (*Shell) SetSize

func (s *Shell) SetSize(cols, rows uint16) (e error)

SetSize .

func (*Shell) Unattack

func (s *Shell) Unattack(ws *websocket.Conn)

Unattack .

func (*Shell) Write

func (s *Shell) Write(b []byte) (int, error)

Write .

Directories

Path Synopsis
internal

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