agent

package
v0.8.12 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: AGPL-3.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProtocolReconnectingPTY = "reconnecting-pty"
	ProtocolSSH             = "ssh"
	ProtocolDial            = "dial"

	// MagicSessionErrorCode indicates that something went wrong with the session, rather than the
	// command just returning a nonzero exit code, and is chosen as an arbitrary, high number
	// unlikely to shadow other exit codes, which are typically 1, 2, 3, etc.
	MagicSessionErrorCode = 229
)

Variables

This section is empty.

Functions

func Bicopy added in v0.5.11

func Bicopy(ctx context.Context, c1, c2 io.ReadWriteCloser)

Bicopy copies all of the data between the two connections and will close them after one or both of them are done writing. If the context is canceled, both of the connections will be closed.

func ExpandRelativeHomePath added in v0.5.11

func ExpandRelativeHomePath(in string) (string, error)

ExpandRelativeHomePath expands the tilde at the beginning of a path to the current user's home directory and returns a full absolute path.

func New

func New(options Options) io.Closer

Types

type Conn

type Conn interface {
	io.Closer
	Closed() <-chan struct{}
	Ping() (time.Duration, error)
	CloseWithError(err error) error
	ReconnectingPTY(id string, height, width uint16, command string) (net.Conn, error)
	SSH() (net.Conn, error)
	Speedtest(direction speedtest.Direction, duration time.Duration) ([]speedtest.Result, error)
	SSHClient() (*ssh.Client, error)
	DialContext(ctx context.Context, network string, addr string) (net.Conn, error)
}

Conn is a temporary interface while we switch from WebRTC to Wireguard networking.

type CoordinatorDialer added in v0.8.11

type CoordinatorDialer func(ctx context.Context) (net.Conn, error)

CoordinatorDialer is a function that constructs a new broker. A dialer must be passed in to allow for reconnects.

type FetchMetadata added in v0.8.11

type FetchMetadata func(ctx context.Context) (Metadata, error)

FetchMetadata is a function to obtain metadata for the agent.

type Metadata added in v0.5.1

type Metadata struct {
	DERPMap              *tailcfg.DERPMap  `json:"derpmap"`
	EnvironmentVariables map[string]string `json:"environment_variables"`
	StartupScript        string            `json:"startup_script"`
	Directory            string            `json:"directory"`
}

type Options

type Options struct {
	CoordinatorDialer CoordinatorDialer
	WebRTCDialer      WebRTCDialer
	FetchMetadata     FetchMetadata

	StatsReporter          StatsReporter
	ReconnectingPTYTimeout time.Duration
	EnvironmentVariables   map[string]string
	Logger                 slog.Logger
}

type ReconnectingPTYRequest added in v0.5.2

type ReconnectingPTYRequest struct {
	Data   string `json:"data"`
	Height uint16 `json:"height"`
	Width  uint16 `json:"width"`
}

ReconnectingPTYRequest is sent from the client to the server to pipe data to a PTY.

type Stats added in v0.8.12

type Stats struct {
	NumConns int64 `json:"num_comms"`
	RxBytes  int64 `json:"rx_bytes"`
	TxBytes  int64 `json:"tx_bytes"`
}

Stats records the Agent's network connection statistics for use in user-facing metrics and debugging. Each member value must be written and read with atomic.

func (*Stats) Copy added in v0.8.12

func (s *Stats) Copy() *Stats

type StatsReporter added in v0.8.12

type StatsReporter func(
	ctx context.Context,
	log slog.Logger,
	stats func() *Stats,
) (io.Closer, error)

StatsReporter periodically accept and records agent stats.

type TailnetConn added in v0.8.11

type TailnetConn struct {
	*tailnet.Conn
	CloseFunc func()
}

func (*TailnetConn) Close added in v0.8.11

func (c *TailnetConn) Close() error

func (*TailnetConn) CloseWithError added in v0.8.11

func (c *TailnetConn) CloseWithError(_ error) error

func (*TailnetConn) DialContext added in v0.8.11

func (c *TailnetConn) DialContext(ctx context.Context, network string, addr string) (net.Conn, error)

func (*TailnetConn) Ping added in v0.8.11

func (c *TailnetConn) Ping() (time.Duration, error)

func (*TailnetConn) ReconnectingPTY added in v0.8.11

func (c *TailnetConn) ReconnectingPTY(id string, height, width uint16, command string) (net.Conn, error)

func (*TailnetConn) SSH added in v0.8.11

func (c *TailnetConn) SSH() (net.Conn, error)

func (*TailnetConn) SSHClient added in v0.8.11

func (c *TailnetConn) SSHClient() (*ssh.Client, error)

SSHClient calls SSH to create a client that uses a weak cipher for high throughput.

func (*TailnetConn) Speedtest added in v0.8.12

func (c *TailnetConn) Speedtest(direction speedtest.Direction, duration time.Duration) ([]speedtest.Result, error)

type WebRTCConn added in v0.8.11

type WebRTCConn struct {
	// Negotiator is responsible for exchanging messages.
	Negotiator proto.DRPCPeerBrokerClient

	*peer.Conn
}

Conn wraps a peer connection with helper functions to communicate with the agent.

func (*WebRTCConn) Close added in v0.8.11

func (c *WebRTCConn) Close() error

func (*WebRTCConn) DialContext added in v0.8.11

func (c *WebRTCConn) DialContext(ctx context.Context, network string, addr string) (net.Conn, error)

DialContext dials an arbitrary protocol+address from inside the workspace and proxies it through the provided net.Conn.

func (*WebRTCConn) ReconnectingPTY added in v0.8.11

func (c *WebRTCConn) ReconnectingPTY(id string, height, width uint16, command string) (net.Conn, error)

ReconnectingPTY returns a connection serving a TTY that can be reconnected to via ID.

The command is optional and defaults to start a shell.

func (*WebRTCConn) SSH added in v0.8.11

func (c *WebRTCConn) SSH() (net.Conn, error)

SSH dials the built-in SSH server.

func (*WebRTCConn) SSHClient added in v0.8.11

func (c *WebRTCConn) SSHClient() (*ssh.Client, error)

SSHClient calls SSH to create a client that uses a weak cipher for high throughput.

func (*WebRTCConn) Speedtest added in v0.8.12

type WebRTCDialer added in v0.8.11

type WebRTCDialer func(ctx context.Context, logger slog.Logger) (*peerbroker.Listener, error)

Directories

Path Synopsis
Package reaper contains logic for reaping subprocesses.
Package reaper contains logic for reaping subprocesses.

Jump to

Keyboard shortcuts

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