communication

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VersionString = "SSH-2.0-VIC"
	ClientTimeout = 10 * time.Second
)

Variables

This section is empty.

Functions

func ContainerIDs

func ContainerIDs(conn ssh.Conn) ([]string, error)

ContainerIDs asks the ids of the containers on the other hand and return them to the caller

func ContainerVersion

func ContainerVersion(conn ssh.Conn) (uint32, error)

ContainerVersion asks the version of the containers on the other hand and return them to the caller

Types

type Connector

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

Connector defines the connection and interactions

func NewConnector

func NewConnector(listener net.Listener) *Connector

NewConnector returns a new Connector

func (*Connector) Interaction

func (c *Connector) Interaction(ctx context.Context, id string) (SessionInteractor, error)

Interaction returns the interactor corresponding to the specified ID. If the connection doesn't exist the method will wait for the specified timeout, returning when the connection is created or the timeout expires, whichever occurs first

func (*Connector) RemoveInteraction

func (c *Connector) RemoveInteraction(id string) error

RemoveInteraction removes the session the inteactions map

func (*Connector) SessionIfAlive

func (c *Connector) SessionIfAlive(ctx context.Context, id string) (SessionInteractor, error)

SessionIfAlive returns SessionInteractor or error

func (*Connector) Start

func (c *Connector) Start()

Start starts the connector

func (*Connector) Stop

func (c *Connector) Stop()

Stop stops the connector

type LazyInitializer

type LazyInitializer func() (SessionInteractor, error)

LazyInitializer defines the function that returns SessionInteractor

type LazySessionInteractor

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

LazySessionInteractor holds lazily initialized SessionInteractor

func (*LazySessionInteractor) Initialize

func (l *LazySessionInteractor) Initialize() (SessionInteractor, error)

Initialize either returns either already initialized connection or returns the connection after initializing it

func (*LazySessionInteractor) SessionInteractor

func (l *LazySessionInteractor) SessionInteractor() SessionInteractor

SessionInteractor returns either an initialized connection, or nil if it was never initialized

type Server

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

Server waits for TCP client connections on serialOverLANPort, then once connected, attempts to negotiate an SSH connection to the attached client. The client is the ssh server.

func NewServer

func NewServer(ip string, port int) *Server

NewServer returns a Server instance

func (*Server) Addr

func (n *Server) Addr() string

Addr returns the address of the underlying listener

func (*Server) Interaction

func (n *Server) Interaction(ctx context.Context, id string) (SessionInteractor, error)

Interaction returns the session interface for the given container. If the container cannot be found, this call will wait for the given timeout. id is ID of the container.

func (*Server) RemoveInteraction

func (n *Server) RemoveInteraction(id string) error

RemoveInteraction removes the session interface from underlying connector

func (*Server) Start

func (n *Server) Start() error

Start starts the connector with given listener

func (*Server) Stop

func (n *Server) Stop() error

Stop stops the connector

type SessionInteractor

type SessionInteractor interface {
	// Send specific signal
	Signal(signal ssh.Signal) error
	// Stdout stream
	Stdout() io.Reader
	// Stderr stream
	Stderr() io.Reader
	// Stdin stream
	Stdin() io.WriteCloser
	Close() error

	// Resize the terminal
	Resize(cols, rows, widthpx, heightpx uint32) error

	CloseStdin() error

	Ping() error
	Unblock() error
}

SessionInteractor defines the interaction interface

func NewSSHInteraction

func NewSSHInteraction(conn ssh.Conn, id string, version uint32) (SessionInteractor, error)

NewSSHInteraction returns a stream connection to the requested session The ssh conn is assumed to be connected to the Executor hosting the session

Jump to

Keyboard shortcuts

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