shellconsts

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: May 24, 2018 License: MPL-2.0 Imports: 1 Imported by: 1

Documentation

Overview

Package shellconsts contains constants shared between shell server and client which is split into different packages to reduce the binary size of potential commandline clients.

Index

Constants

View Source
const (
	MessageTypeData  = 0
	MessageTypeAck   = 1
	MessageTypeSize  = 3
	MessageTypeAbort = 4
	MessageTypeExit  = 5
	StreamStdin      = 0
	StreamStdout     = 1
	StreamStderr     = 2
)

Message type codes for websocket messages implementing interactive shell.

We will send stdin, stdout, stderr, exit and abort messages over a websocket. Messages will all have the form: [type] [data]

Where [type] is a single byte with the value of MessageTypeData MessageTypeAbort or MessageTypeExit. The data property depends on the [type] of the message, as outlined below.

If [type] is MessageTypeData then

[data] = [stream] [payload]

, where [stream] is a single byte: StreamStdin, StreamStdout, StreamStderr, and [payload] is data from this stream. If [payload] is an empty byte sequence this signals the end of the stream.

If [type] is MessageTypeAck then

[data] = [stream] [N]

, where [stream] is a single byte: StreamStdin, StreamStdout, StreamStderr, and [N] is a big-endian 32 bit unsigned integer acknowleging the remote stream to have processed N bytes.

If [type] is MessageTypeAbort then [data] is empty, this message is used to request that the executing be aborted.

If [type] is MessageTypeExit then [data] = [exitCode], where exitCode is a single byte 0 (success) or 1 (failed) indicating whether the command terminated successfully.

If [type] is MessageTypeSize then

[data] = [colmns] [rows]

, where [colmns] and [rows] are big-endian 16 bit unsigned integers specifying the width and height of the TTY. If not supported this message is is ignored.

View Source
const (
	// ShellHandshakeTimeout is the maximum allowed time for websocket handshake
	ShellHandshakeTimeout = 30 * time.Second
	// ShellPingInterval is the time between sending pings
	ShellPingInterval = 15 * time.Second
	// ShellWriteTimeout is the maximum time between successful writes
	ShellWriteTimeout = ShellPingInterval * 2
	// ShellPongTimeout is the maximum time between successful reads
	ShellPongTimeout = ShellPingInterval * 3
	// ShellBlockSize is the maximum number of bytes to send in a single block
	ShellBlockSize = 16 * 1024
	// ShellMaxMessageSize is the maximum message size we will read
	ShellMaxMessageSize = ShellBlockSize + 4*1024
	// ShellMaxPendingBytes is the maximum number of bytes allowed in-flight
	ShellMaxPendingBytes = 4 * ShellBlockSize
)

Variables

This section is empty.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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