proxy

package
v0.0.0-...-3b91d86 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2019 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Proxy

func Proxy(ctx context.Context, id string, conn Conn, cli client.CommonAPIClient, command Command) error

Proxy attaches to a docker container and proxies its stdin/out/err over a websocket using the terminado protocol.

func RuneCopy

func RuneCopy(dst io.Writer, src io.Reader) (written int, err error)

RuneCopy is like io.Copy, but only writes valid runes, waiting for more input if invalid. This uses ScanRunesGreedy to write as much as possible per read.

func ScanRunesGreedy

func ScanRunesGreedy(data []byte, atEOF bool) (advance int, token []byte, err error)

ScanRunesGreedy is like bufio.ScanRunes, but will capture as many runes from the input as possible.

func WSIsClose

func WSIsClose(err error) bool

WSIsClose returns true if the error provided is a normal closure error and can be ignored. This includes io.EOF and a wsutil.ClosedError with the code set to StatusNormalClosure or StatusGoingAway.

Types

type Command

type Command struct {
	User       string
	Cmd        []string
	Env        []string
	WorkingDir string
}

Command is the configuration for a proxy'd command.

type Conn

type Conn interface {
	ReadJSON(v interface{}) error
	WriteJSON(v interface{}) error
	Close() error
	IsClose(error) bool
}

Conn is the interface for sending proxy data to the client.

type WSConn

type WSConn struct {
	// contains filtered or unexported fields
}

WSConn wraps a gobwas/ws connection.

func NewWSConn

func NewWSConn(conn net.Conn) *WSConn

NewWSConn creates a new WSConn from a net.Conn.

func (*WSConn) Close

func (w *WSConn) Close() error

Close closes the connection.

func (*WSConn) IsClose

func (w *WSConn) IsClose(err error) bool

IsClose returns true if the error is a close. See WSIsClose.

func (*WSConn) ReadJSON

func (w *WSConn) ReadJSON(v interface{}) error

ReadJSON parses the next text websocket text message into JSON.

func (*WSConn) WriteJSON

func (w *WSConn) WriteJSON(v interface{}) error

WriteJSON writes a value to the websocket as JSON. It is safe for concurrent use.

Jump to

Keyboard shortcuts

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