wush

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2020 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package wush is Coder Enterprise's protocol for transmitting Linux command execution over a WebSocket connection. It provides stdin, stdout, tty information, and exit code.

This package provides the protocol, but no facilities beyond that for creating a wush server. This protocol was designed haphazardly and will likely be rebuild in the near term.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Stdin  io.WriteCloser
	Stdout io.Reader
	Stderr io.Reader
	// contains filtered or unexported fields
}

Client converts a Wush connection into OS streams.

func NewClient

func NewClient(ctx context.Context, conn *websocket.Conn) *Client

NewClient begins multiplexing the Wush connection into independent streams. It will cancel all goroutines when the provided context cancels.

func (*Client) Resize

func (c *Client) Resize(width, height int) error

func (*Client) Wait

func (c *Client) Wait() (uint8, error)

Wait returns the status code of the command, along with any error.

type ClientMessage

type ClientMessage struct {
	Type ClientMsgType `json:"type"`

	// Valid on "input" messages.
	// Because this encodes everything in base64, it will case ~30% performance
	// overhead.
	Input string `json:"input"`

	// Valid on "resize" messages.
	Height int `json:"height"`
	Width  int `json:"width"`
}

ClientMessage is sent from the local client to the wush server.

type ClientMsgType

type ClientMsgType int

ClientMsgType specifies the type of a wush lite message from the client.

const (
	Stdin ClientMsgType = iota
	Resize
	CloseStdin
)

type ServerMessage

type ServerMessage struct {
	StreamID byte
	Body     io.Reader
}

ServerMessage is sent over websocket type binary.

type StreamID

type StreamID byte

StreamID specifies the kind of data being transmitted.

const (
	Stdout StreamID = 0
	Stderr StreamID = 1

	// StreamID is a special stream ID, where the data is just a
	// single byte representing the exit code of the process.
	ExitCode StreamID = 255
)

Wush lite output stream IDs.

Jump to

Keyboard shortcuts

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