hosts

package
v0.6.1-rc1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2022 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BinaryWriter added in v0.4.3

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

BinaryWriter struct for binary writer.

func NewBinaryWriter added in v0.4.3

func NewBinaryWriter(con *websocket.Conn) *BinaryWriter

NewBinaryWriter returns new binary writer.

func (*BinaryWriter) Write added in v0.4.3

func (s *BinaryWriter) Write(p []byte) (int, error)

Write binary writer Write implement.

type Dialer

type Dialer interface {
	SetIO(stdout, stderr io.Writer, stdin io.ReadCloser)
	SetWindowSize(height, weight int)
	ChangeWindowSize(win *WindowSize) error
	OpenTerminal() error
	Wait() error
	Write(b []byte) error
	Close() error
}

Dialer dialer interface definition.

type DockerDialer added in v0.4.3

type DockerDialer struct {
	Stdin  io.ReadCloser
	Stdout io.Writer
	Stderr io.Writer
	Writer io.Writer

	Height int
	Weight int
	// contains filtered or unexported fields
}

DockerDialer struct for docker dialer.

func NewDockerDialer added in v0.4.3

func NewDockerDialer(n *types.Node) (*DockerDialer, error)

NewDockerDialer returns new docker dialer.

func (*DockerDialer) ChangeWindowSize added in v0.4.4

func (d *DockerDialer) ChangeWindowSize(win *WindowSize) error

ChangeWindowSize change tty window size for websocket.

func (*DockerDialer) Close added in v0.4.3

func (d *DockerDialer) Close() error

Close close the Docker connection.

func (*DockerDialer) ExecStart added in v0.4.3

func (d *DockerDialer) ExecStart(needRestore bool) error

ExecStart handles setting up the IO and then begins streaming stdin/stdout to/from the hijacked connection, blocking until it is either done reading output, the user inputs the detach key sequence when in TTY mode, or when the given context is cancelled. Borrowed from https://github.com/docker/cli/blob/master/cli/command/container/hijack.go#L40.

func (*DockerDialer) MonitorTtySize added in v0.4.3

func (d *DockerDialer) MonitorTtySize(ctx context.Context) error

MonitorTtySize monitor and change tty size. Borrowed from https://github.com/docker/cli/blob/master/cli/command/container/tty.go#L71.

func (*DockerDialer) OpenTerminal added in v0.4.4

func (d *DockerDialer) OpenTerminal() error

OpenTerminal open docker websocket terminal.

func (*DockerDialer) ResizeTty added in v0.4.3

func (d *DockerDialer) ResizeTty(ctx context.Context) error

ResizeTty changes to the current win size.

func (*DockerDialer) ResizeTtyTo added in v0.4.3

func (d *DockerDialer) ResizeTtyTo(ctx context.Context, height, width uint) error

ResizeTtyTo changes the size of the tty for an exec process running inside a container.

func (*DockerDialer) SetIO added in v0.4.4

func (d *DockerDialer) SetIO(stdout, stderr io.Writer, stdin io.ReadCloser)

SetIO set dialer's reader and writer.

func (*DockerDialer) SetStdio added in v0.4.3

func (d *DockerDialer) SetStdio(stdout, stderr io.Writer, stdin io.ReadCloser) *DockerDialer

SetStdio set dialer's reader and writer.

func (*DockerDialer) SetWindowSize added in v0.4.4

func (d *DockerDialer) SetWindowSize(height, weight int)

SetWindowSize set dialer's default win size.

func (*DockerDialer) SetWriter added in v0.4.3

func (d *DockerDialer) SetWriter(w io.Writer) *DockerDialer

SetWriter set dialer's logs writer.

func (*DockerDialer) Terminal added in v0.4.3

func (d *DockerDialer) Terminal() error

Terminal open docker exec terminal.

func (*DockerDialer) Wait added in v0.4.4

func (d *DockerDialer) Wait() error

Wait waits for the command to exit. Borrowed from https://github.com/docker/cli/blob/master/cli/command/container/exec.go#L180.

func (*DockerDialer) Write added in v0.4.4

func (d *DockerDialer) Write(b []byte) error

Write write implement.

type PtyDialer added in v0.4.3

type PtyDialer struct {
	Stdin  io.ReadCloser
	Stdout io.Writer
	Stderr io.Writer
	Writer io.Writer

	Height int
	Weight int
	// contains filtered or unexported fields
}

PtyDialer struct for pty dialer.

func NewPtyDialer added in v0.4.3

func NewPtyDialer(cmd *exec.Cmd) (*PtyDialer, error)

NewPtyDialer returns new pty dialer struct.

func (*PtyDialer) ChangeWindowSize added in v0.4.4

func (d *PtyDialer) ChangeWindowSize(win *WindowSize) error

ChangeWindowSize changes to the current window size.

func (*PtyDialer) Close added in v0.4.3

func (d *PtyDialer) Close() error

Close close the pty connection.

func (*PtyDialer) OpenTerminal added in v0.4.4

func (d *PtyDialer) OpenTerminal() error

OpenTerminal open pty websocket terminal.

func (*PtyDialer) SetIO added in v0.4.4

func (d *PtyDialer) SetIO(stdout, stderr io.Writer, stdin io.ReadCloser)

SetIO set dialer's reader and writer.

func (*PtyDialer) SetWindowSize added in v0.4.4

func (d *PtyDialer) SetWindowSize(height, weight int)

SetWindowSize set tty window size size.

func (*PtyDialer) Wait added in v0.4.4

func (d *PtyDialer) Wait() error

Wait waits for the command to exit.

func (*PtyDialer) Write added in v0.4.4

func (d *PtyDialer) Write(b []byte) error

type SSHDialer

type SSHDialer struct {
	Stdin  io.ReadCloser
	Stdout io.Writer
	Stderr io.Writer
	Writer io.Writer

	Height int
	Weight int

	Term  string
	Modes ssh.TerminalModes
	// contains filtered or unexported fields
}

SSHDialer struct for ssh dialer.

func NewSSHDialer added in v0.4.3

func NewSSHDialer(n *types.Node, timeout bool) (*SSHDialer, error)

NewSSHDialer returns new ssh dialer.

func (*SSHDialer) ChangeWindowSize added in v0.4.4

func (d *SSHDialer) ChangeWindowSize(win *WindowSize) error

ChangeWindowSize change the window size for current session.

func (*SSHDialer) Close added in v0.4.3

func (d *SSHDialer) Close() error

Close close the SSH connection.

func (*SSHDialer) Cmd added in v0.4.3

func (d *SSHDialer) Cmd(cmd string) *SSHDialer

Cmd pass commands in dialer, support multiple calls, e.g. d.Cmd("ls").Cmd("id").

func (*SSHDialer) Dial added in v0.4.3

func (d *SSHDialer) Dial(t bool) (*ssh.Client, error)

Dial handshake with ssh address.

func (*SSHDialer) GetClient added in v0.6.0

func (d *SSHDialer) GetClient() *ssh.Client

func (*SSHDialer) NewSession added in v0.4.4

func (d *SSHDialer) NewSession() error

NewSession returns new session.

func (*SSHDialer) OpenTerminal added in v0.4.4

func (d *SSHDialer) OpenTerminal() error

OpenTerminal starts a login shell on the remote host.

func (*SSHDialer) Run added in v0.4.3

func (d *SSHDialer) Run() error

Run commands in remote server via SSH tunnel.

func (*SSHDialer) SetIO added in v0.4.4

func (d *SSHDialer) SetIO(stdout, stderr io.Writer, stdin io.ReadCloser)

SetIO set dialer's reader and writer.

func (*SSHDialer) SetStdio added in v0.4.3

func (d *SSHDialer) SetStdio(stdout, stderr io.Writer, stdin io.ReadCloser) *SSHDialer

SetStdio set dialer's reader and writer.

func (*SSHDialer) SetWindowSize added in v0.4.4

func (d *SSHDialer) SetWindowSize(height, weight int)

SetWindowSize set dialer's default window size.

func (*SSHDialer) SetWriter added in v0.4.3

func (d *SSHDialer) SetWriter(w io.Writer) *SSHDialer

SetWriter set dialer's logs writer.

func (*SSHDialer) Terminal added in v0.4.3

func (d *SSHDialer) Terminal() error

Terminal starts a login shell on the remote host for CLI.

func (*SSHDialer) Wait added in v0.4.4

func (d *SSHDialer) Wait() error

Wait waits for the remote command to exit.

func (*SSHDialer) Write added in v0.4.4

func (d *SSHDialer) Write(b []byte) error

type TerminalReader added in v0.4.3

type TerminalReader struct {
	ClosedCh chan bool
	// contains filtered or unexported fields
}

TerminalReader struct for terminal reader.

func NewTerminalReader added in v0.4.3

func NewTerminalReader(con *websocket.Conn) *TerminalReader

NewTerminalReader returns new terminal reader.

func (*TerminalReader) Close added in v0.4.3

func (t *TerminalReader) Close() error

Close used to close terminal reader.

func (*TerminalReader) Read added in v0.4.3

func (t *TerminalReader) Read(p []byte) (int, error)

Read terminal reader Read implement.

func (*TerminalReader) SetResizeFunction added in v0.4.3

func (t *TerminalReader) SetResizeFunction(resizeFun func(size *WindowSize))

SetResizeFunction set terminal reader resize function.

type WebSocketDialer added in v0.4.3

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

WebSocketDialer struct for websocket dialer.

func NewWebSocketDialer added in v0.4.3

func NewWebSocketDialer(conn *websocket.Conn, dialer Dialer) *WebSocketDialer

NewWebSocketDialer returns new websocket dialer.

func (*WebSocketDialer) ChangeWindowSize added in v0.4.3

func (d *WebSocketDialer) ChangeWindowSize(win *WindowSize)

ChangeWindowSize change websocket win size.

func (*WebSocketDialer) Close added in v0.4.3

func (d *WebSocketDialer) Close()

Close close the WebSocket connection.

func (*WebSocketDialer) ReadMessage added in v0.4.3

func (d *WebSocketDialer) ReadMessage(ctx context.Context) error

ReadMessage read websocket message.

func (*WebSocketDialer) SetDefaultSize added in v0.4.3

func (d *WebSocketDialer) SetDefaultSize(height, weight int)

SetDefaultSize set dialer's default window size.

func (*WebSocketDialer) Terminal added in v0.4.3

func (d *WebSocketDialer) Terminal() error

Terminal open websocket terminal.

func (*WebSocketDialer) Write added in v0.4.3

func (d *WebSocketDialer) Write(bytes []byte) error

Write write bytes to the websocket connection.

type WindowSize added in v0.4.3

type WindowSize struct {
	Width  int
	Height int
}

WindowSize struct for window size.

Jump to

Keyboard shortcuts

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