eows

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package eows is used to Execute commands Over WebSocket

Package eows is used to Execute commands Over WebSocket

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DoneChan

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

DoneChan Channel used to propagate status+error on command exit

type EmitExitCB

type EmitExitCB func(e *ExecOverWS, code int, err error)

EmitExitCB is the function callback used to emit exit proc code

type EmitOutputCB

type EmitOutputCB func(e *ExecOverWS, stdout, stderr []byte)

EmitOutputCB is the function callback used to emit data

type ExecOverWS

type ExecOverWS struct {
	Cmd      string           // command name to execute
	Args     []string         // command arguments
	SocketIO *socketio.Socket // websocket
	Sid      string           // websocket ID
	CmdID    string           // command ID

	// Optional fields
	Env            []string                // command environment variables
	CmdExecTimeout int                     // command execution time timeout
	Log            *logrus.Logger          // logger (nil if disabled)
	InputEvent     string                  // websocket input event name
	InputCB        OnInputCB               // stdin callback
	OutputCB       EmitOutputCB            // stdout/stderr callback
	ExitCB         EmitExitCB              // exit proc callback
	UserData       *map[string]interface{} // user data passed to callbacks
	OutSplit       SplitType               // split method to tokenize stdout/stderr
	LineTimeSpan   int64                   // time span (only used with SplitTime or SplitLineTime)
	PtyMode        bool                    // Allocate a pseudo-terminal (allow to execute screen-based program)
	PtyTermEcho    bool                    // Turn on/off terminal echo
	// contains filtered or unexported fields
}

ExecOverWS .

func GetEows

func GetEows(cmdID string) *ExecOverWS

GetEows gets ExecOverWS object from command ID

func New

func New(cmd string, args []string, so *socketio.Socket, soID, cmdID string) *ExecOverWS

New creates a new instace of eows

func (*ExecOverWS) Signal

func (e *ExecOverWS) Signal(signal string) error

Signal sends a signal to the running command / process

func (*ExecOverWS) Start

func (e *ExecOverWS) Start() error

Start executes the command and redirect stdout/stderr into a WebSocket

func (*ExecOverWS) TerminalSetSize added in v0.2.0

func (e *ExecOverWS) TerminalSetSize(rows, cols uint16) error

TerminalSetSize Set terminal size

func (*ExecOverWS) TerminalSetSizePos added in v0.2.0

func (e *ExecOverWS) TerminalSetSizePos(rows, cols, x, y uint16) error

TerminalSetSizePos Set terminal size and position

type OnInputCB

type OnInputCB func(e *ExecOverWS, stdin []byte) ([]byte, error)

OnInputCB is the function callback used to receive data

type SplitType added in v0.1.8

type SplitType uint8

SplitType Type of spliting method to tokenize stdout/stderr

const (
	// SplitLine Split line by line
	SplitLine SplitType = iota
	// SplitChar Split character by character
	SplitChar
	// SplitLineTime Split by line or until a timeout has passed
	SplitLineTime
	// SplitTime Split until a timeout has passed
	SplitTime
)

Jump to

Keyboard shortcuts

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