Back to

Package wsep

Latest Go to latest

The highest tagged major version is .

Published: 3 days ago | License: MIT | Module:


func Serve

func Serve(ctx context.Context, c *websocket.Conn, execer Execer) error

Serve runs the server-side of wsep. The execer may be another wsep connection for chaining. Use LocalExecer for local command execution.

type Command

type Command struct {
	Command    string
	Args       []string
	TTY        bool
	Stdin      bool
	UID        uint32
	GID        uint32
	Env        []string
	WorkingDir string

Command represents an external command to be run

type Execer

type Execer interface {
	Start(ctx context.Context, c Command) (Process, error)

Execer starts commands.

func RemoteExecer

func RemoteExecer(conn *websocket.Conn) Execer

RemoteExecer creates an execution interface from a WebSocket connection.

type ExitError

type ExitError struct {
	Code int

ExitError is sent when the command terminates.

func (ExitError) Error

func (e ExitError) Error() string

type LocalExecer

type LocalExecer struct {
	// ChildProcessPriority overrides the default niceness of all child processes launch by LocalExecer.
	ChildProcessPriority *int

LocalExecer executes command on the local system.

func (LocalExecer) Start

func (l LocalExecer) Start(ctx context.Context, c Command) (Process, error)

Start executes the given command locally

type Process

type Process interface {
	// Pid is populated immediately during a successful start with the process ID.
	Pid() int
	// Stdout returns an io.WriteCloser that will pipe writes to the remote command.
	// Closure of stdin sends the corresponding close message.
	Stdin() io.WriteCloser
	// Stdout returns an io.Reader that is connected to the command's standard output.
	Stdout() io.Reader
	// Stderr returns an io.Reader that is connected to the command's standard error.
	Stderr() io.Reader
	// Resize resizes the TTY if a TTY is enabled.
	Resize(ctx context.Context, rows, cols uint16) error
	// Wait returns ExitError when the command terminates with a non-zero exit code.
	Wait() error
	// Close terminates the process and underlying connection(s).
	// It must be called otherwise a connection or process may leak.
	Close() error

Process represents a started command.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier