wsexec

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2021 License: MIT Imports: 13 Imported by: 0

README

Introduction

websocket client and server lib for kubernetes exec command.

Install

go get github.com/lixianyang/wsexec

Example

server

Change kubeconfig load way if needed.

See examples

cd example/server
go mod tidy
go run main.go

client

Change namespace, pod and command before run main.go

See examples

cd example/client
go mod tidy
go run main.go

Documentation

Index

Constants

View Source
const (
	EndOfTransmission = "\u0004"
	Escape            = '\u001b'
)

Variables

View Source
var (
	ErrTerminalSizeMonitorStopped = errors.New("terminal size monitor has been stopped")
	ErrUnexpectedMessageType      = errors.New("received unexpected message type")
)

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(conn *websocket.Conn, options ...ClientOption) *Client

func (*Client) Run

func (cli *Client) Run() error

type ClientOption

type ClientOption func(cli *Client)

func WithClientDebugInput

func WithClientDebugInput(writer io.Writer) ClientOption

func WithClientLogger

func WithClientLogger(logger Logger) ClientOption

func WithClientTTY

func WithClientTTY(tty term.TTY) ClientOption

type Logger

type Logger interface {
	Printfln(format string, a ...interface{})
	Println(a ...interface{})
}

func NewLogger

func NewLogger(writer io.Writer) Logger

type Server

type Server struct {
	sync.Mutex // write lock
	// contains filtered or unexported fields
}

func NewServer

func NewServer(conn *websocket.Conn, options ...ServerOption) *Server

func (*Server) Close

func (s *Server) Close(err error)

func (*Server) Keepalive

func (s *Server) Keepalive()

func (*Server) Next

func (s *Server) Next() *remotecommand.TerminalSize

func (*Server) Ping

func (s *Server) Ping() error

func (*Server) Read

func (s *Server) Read(p []byte) (n int, err error)

func (*Server) Write

func (s *Server) Write(p []byte) (n int, err error)

type ServerOption

type ServerOption func(s *Server)

func WithServerCloseTimeout

func WithServerCloseTimeout(d time.Duration) ServerOption

func WithServerDebugInput

func WithServerDebugInput(writer io.Writer) ServerOption

func WithServerDebugOutput

func WithServerDebugOutput(writer io.Writer) ServerOption

func WithServerLogger

func WithServerLogger(logger Logger) ServerOption

func WithServerPingInterval

func WithServerPingInterval(d time.Duration) ServerOption

func WithServerPingTimeout

func WithServerPingTimeout(d time.Duration) ServerOption

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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