tty

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxBufferSize = 1024 * 1024 * 1
)
View Source
const MetricsInterval = 1 * time.Second

Variables

View Source
var (
	// ErrSlaveClosed indicates the function has exited by the slave
	ErrSlaveClosed = errors.New("slave closed")

	// ErrSlaveClosed is returned when the slave connection is closed.
	ErrMasterClosed = errors.New("master closed")

	// ErrConnectionLostPing is returned if no ping within a duration
	ErrConnectionLostPing = errors.New("connection lost ping")
)

Functions

This section is empty.

Types

type ArgResizeTerminal

type ArgResizeTerminal struct {
	Columns int
	Rows    int
}

type Factory

type Factory interface {
	Name() string
	New(params map[string][]string) (Slave, error)
}

type Hook

type Hook func(r *Recorder) error

type Master

type Master io.ReadWriter

type Option

type Option func(*ProxyTTY) error

Option is an option for WebTTY.

func WithPermitWrite

func WithPermitWrite() Option

WithPermitWrite sets a ProxyTTY to accept input from slaves.

func WithTtyRecording

func WithTtyRecording(parent context.Context, filePrefix, fileName string, finishedHandler Hook) Option

type ProxyTTY

type ProxyTTY struct {
	ResizeEvents chan *ArgResizeTerminal
	// contains filtered or unexported fields
}

ProxyTTY bridges a PTY slave and its PTY master. To support text-based streams and side channel commands such as terminal resizing, ProxyTTY uses an original protocol.

func New

func New(masterStdin io.Reader, masterStdout io.Writer, slave Slave, options ...Option) (*ProxyTTY, error)

func (*ProxyTTY) Run

func (ptty *ProxyTTY) Run(ctx context.Context) error

Run starts the main process of the PProxyTTY This method blocks until the context is canceled. Note that the master and slave are left intact even after the context is canceled. Closing them is caller's responsibility. If the connection to one end gets closed, returns ErrSlaveClosed or ErrMasterClosed.

type Recorder

type Recorder struct {
	Hook            Hook
	FileName        string
	FilePrefix      string
	KeystrokesMeter metrics.Meter
	OutputMeter     metrics.Meter
	Cancel          context.CancelFunc
	// contains filtered or unexported fields
}

func (Recorder) Write

func (r Recorder) Write(data []byte) (int, error)

type Slave

type Slave interface {
	io.ReadWriter

	// WindowTitleVariables returns any values that can be used to fill out
	// the title of a terminal.
	WindowTitleVariables() map[string]interface{}

	// ResizeTerminal sets a new size of the terminal.
	ResizeTerminal(columns int, rows int) error

	Close() error
}

Slave represents a PTY slave, typically it's a local command.

Jump to

Keyboard shortcuts

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