shell

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package shell pipes a Mist remote shell websocket to a terminal.

Framing (same as the mistapi Python package): keystrokes are sent as binary frames prefixed with a 0x00 byte, terminal size changes as a text frame {"resize":{"width":W,"height":H}}, and everything the device sends is raw terminal output.

Index

Constants

This section is empty.

Variables

View Source
var ErrEscape = errors.New("session closed with ~.")

ErrEscape is returned when the user ended the session with "~.".

View Source
var ErrLost = errors.New("connection lost: the server stopped responding")

ErrLost is returned when the server stops answering keepalive pings, for example after the computer slept or the network changed.

Functions

func Run

func Run(ctx context.Context, o Options) error

Run connects to the shell and copies data both ways until the device closes the session, the user types the escape sequence, reading stdin fails or ctx is cancelled. A normal close by the device returns nil.

Types

type Options

type Options struct {
	URL    string
	Header http.Header
	// HTTPClient is used for the websocket handshake (nil: default client).
	HTTPClient *http.Client
	Stdin      io.Reader
	Stdout     io.Writer
	Size       SizeFunc
	// ResizePoll is how often the terminal size is checked (default 250ms).
	// Polling works the same on every OS, including Windows.
	ResizePoll time.Duration
	// ReadyTimeout is how long to hold keystrokes back while waiting for the
	// first output of the device (default 10s).
	ReadyTimeout time.Duration
	// PingInterval is how often a websocket ping checks that the connection
	// is still alive (default 30s; negative disables). A session is only
	// ended for a missed pong once the server has answered one, so a server
	// that never answers pings is not cut off.
	PingInterval time.Duration
	// PingTimeout is how long to wait for a pong (default 15s).
	PingTimeout time.Duration
	// Escape enables the ssh-style "~." (at the start of a line) sequence
	// to end the session locally.
	Escape bool
}

Options configures a shell session.

type SizeFunc

type SizeFunc func() (cols, rows int, ok bool)

SizeFunc returns the current terminal size in columns and rows.

Jump to

Keyboard shortcuts

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