agent

package
v0.0.0-...-82e5c22 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2023 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientTLSConfig

func ClientTLSConfig(caCertPEM []byte, certPEM []byte, keyPEM []byte) (*tls.Config, error)

func HeartbeatFailureExit

func HeartbeatFailureExit()

func HeartbeatFailureShutdown

func HeartbeatFailureShutdown()

func ServerTLSConfig

func ServerTLSConfig(caCertPEM []byte, certPEM []byte, keyPEM []byte) (*tls.Config, error)

Types

type CACert

type CACert struct {
	CertPEMBytes []byte
	KeyPEMBytes  []byte
	// contains filtered or unexported fields
}

type Cert

type Cert struct {
	X509Cert     *x509.Certificate
	CertDER      []byte
	CertPEMBytes []byte
	KeyPEMBytes  []byte
}

type Certs

type Certs struct {
	Server Cert
	Client Cert
	CA     CACert
}

Certs contains the TLS client and server certs and keys for configuring mTLS on the client and server. This contains the secrets necessary for authz, so handle carefully.

func GenerateCerts

func GenerateCerts() (*Certs, error)

GenerateCerts generates TLS CA certs and client & server certs to use for agent traffic.

type Client

type Client struct {
	Logger     *zap.SugaredLogger
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

func NewClient

func NewClient(log *zap.SugaredLogger, certs *Certs, ipAddr string, port int, opts ...ClientOption) (*Client, error)

func (*Client) Dial

func (c *Client) Dial(network, addr string) (net.Conn, error)

Dial establishes a connection to the given address, using the node as a proxy.

func (*Client) DialContext

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

DialContext establishes a connection to the given address using the given network type, tunneled through a WebSocket connection with the node.

func (*Client) Fetch

func (c *Client) Fetch(ctx context.Context, url, path string) error

func (*Client) ReadFile

func (c *Client) ReadFile(ctx context.Context, filePath string) (io.ReadCloser, error)

ReadFile reads a file from the remote node, returning io.ErrNotExist if it is not found.

func (*Client) SendFile

func (c *Client) SendFile(ctx context.Context, filePath string, contents io.Reader) error

func (*Client) SendHeartbeat

func (c *Client) SendHeartbeat(ctx context.Context) error

func (*Client) StartHeartbeat

func (n *Client) StartHeartbeat()

func (*Client) StartProc

func (*Client) StopHeartbeat

func (n *Client) StopHeartbeat()

func (*Client) WaitForServer

func (c *Client) WaitForServer(ctx context.Context) error

type ClientOption

type ClientOption func(c *Client)

func WithClientLogger

func WithClientLogger(l *zap.Logger) ClientOption

func WithClientWaitInterval

func WithClientWaitInterval(d time.Duration) ClientOption

func WithCustomizeRetryableClient

func WithCustomizeRetryableClient(f func(r *retryablehttp.Client)) ClientOption

type ConnectRequest

type ConnectRequest struct {
	Addr    string
	Network string
}

type FetchRequest

type FetchRequest struct {
	URL  string
	Dest string
}

type NodeAgent

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

NodeAgent is an HTTP agent that runs on each node. The agent requires mTLS for both traffic encryption and authz.

func NewNodeAgent

func NewNodeAgent(caCertPEM, certPEM, keyPEM []byte, opts ...Option) (*NodeAgent, error)

NewNodeAgent constructs a new host agent.

func (*NodeAgent) Run

func (a *NodeAgent) Run() error

Run runs the node agent and returns once the node agent has stopped.

func (*NodeAgent) Stop

func (a *NodeAgent) Stop() error

type Option

type Option func(n *NodeAgent)

func WithHeartbeatFailureHandler

func WithHeartbeatFailureHandler(f func()) Option

func WithHeartbeatTimeout

func WithHeartbeatTimeout(d time.Duration) Option

func WithListenAddr

func WithListenAddr(s string) Option

func WithLogLevel

func WithLogLevel(l zapcore.Level) Option

func WithLogger

func WithLogger(l *zap.Logger) Option

type PostCommandRequest

type PostCommandRequest struct {
	Command    string
	Args       []string
	Stdin      string
	Env        []string
	WorkingDir string
}

type PostCommandResponse

type PostCommandResponse struct {
	ExitCode int
	TimeMS   int64
	Stdout   string
	Stderr   string
}

Directories

Path Synopsis
Package process provides a client and server for a remote process runner which streams stdin (client->server) and stdout & stderr (server->client).
Package process provides a client and server for a remote process runner which streams stdin (client->server) and stdout & stderr (server->client).

Jump to

Keyboard shortcuts

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