agentgw

package
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package agentgw is the controller's gRPC endpoint for agents (§12). Agents authenticate with client certificates issued by the internal CA; the node identity is the certificate's CommonName, checked against the nodes table (so deleting a node revokes its certificate).

Index

Constants

This section is empty.

Variables

View Source
var ErrNotConnected = errors.New("node is not connected")

Functions

func ProxyListener added in v0.2.2

func ProxyListener(ln net.Listener) net.Listener

ProxyListener accepts connections that start with a PROXY protocol v1 header (Traefik passing agent.<domain>:443 on): RemoteAddr is then the agent's own address, which the mesh uses as its WireGuard endpoint. The header is read on first use, so a slow client never blocks Accept. A connection without a valid header fails.

Types

type Conn

type Conn struct {
	Node   store.Node
	Hello  *agentv1.Hello
	Remote string // IP address the agent connected from
}

Conn describes a newly connected agent.

type Gateway

type Gateway struct {
	agentv1.UnimplementedAgentGatewayServiceServer
	// contains filtered or unexported fields
}

func New

func New(st *store.Store, registry *nodes.Registry, log *slog.Logger) *Gateway

func (*Gateway) AddHooks

func (g *Gateway) AddHooks(h Hooks)

AddHooks registers h. It must be called before Serve.

func (*Gateway) Send

func (g *Gateway) Send(nodeID string, msg *agentv1.ConnectResponse) error

Send queues a command for a connected node.

func (*Gateway) Serve

func (g *Gateway) Serve(ctx context.Context, ca *pki.CA, addr, proxyAddr string, hosts []string) error

Serve listens on addr with mTLS until ctx ends. hosts are the names and IPs agents use to reach the gateway (put in the server certificate). With proxyAddr set, it also listens there for connections Traefik passes on with a PROXY protocol header (agent.<domain>:443).

func (*Gateway) ServeListener

func (g *Gateway) ServeListener(ctx context.Context, ca *pki.CA, hosts []string, lns ...net.Listener) error

ServeListener is Serve on existing listeners.

func (*Gateway) SetEndpoints added in v0.2.2

func (g *Gateway) SetEndpoints(f func(store.Node) []*agentv1.GatewayEndpoint)

SetEndpoints sets the gateway addresses agents are told to use, in order.

type Hooks

type Hooks struct {
	// OnConnect runs after the Welcome, with the node's Hello (including its
	// container snapshot) and the IP address it connected from.
	OnConnect func(c Conn)
	// OnTaskStatus runs for every task status the agent reports.
	OnTaskStatus func(node store.Node, s *agentv1.TaskStatus)
	// OnTaskEvent runs for every step of a task the agent reports.
	OnTaskEvent func(node store.Node, e *agentv1.TaskEvent)
	// OnHeartbeat runs for every heartbeat.
	OnHeartbeat func(node store.Node, hb *agentv1.Heartbeat)
	// OnDisconnect runs when the stream ends.
	OnDisconnect func(node store.Node)
	// OnLogs runs for every batch of container output.
	OnLogs func(node store.Node, b *agentv1.LogBatch)
	// OnExecOutput runs for output of interactive exec sessions.
	OnExecOutput func(node store.Node, o *agentv1.ExecOutput)
	// OnUpgradeResult runs when an agent reports a failed self-upgrade.
	OnUpgradeResult func(node store.Node, r *agentv1.UpgradeResult)
}

Hooks let other controller components react to agents. Hooks run on the stream's goroutine and must not block.

Jump to

Keyboard shortcuts

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