Documentation
¶
Overview ¶
Package link keeps the agent's connection to the panel: WebSocket over mTLS, hello handshake, and reconnects with backoff (docs/agent-protocol.md in the panel repo).
Index ¶
Constants ¶
const Protocol = 1
Protocol is the protocol version this agent speaks.
Variables ¶
var ErrDisconnected = errors.New("not connected to the panel")
ErrDisconnected is returned by Request while there is no panel connection.
var ErrRevoked = errors.New("the panel rejected this node's certificate (node deleted or re-joined elsewhere); join again")
ErrRevoked means the panel no longer accepts this node's certificate.
Functions ¶
This section is empty.
Types ¶
type Hello ¶
type Hello struct {
Protocol int `json:"protocol"`
AgentVersion string `json:"agent_version"`
Hostname string `json:"hostname"`
OS string `json:"os"`
Kernel string `json:"kernel"`
Arch string `json:"arch"`
CPUs int `json:"cpus"`
MemoryBytes uint64 `json:"memory_bytes"`
DiskBytes uint64 `json:"disk_bytes"`
DiskFreeBytes uint64 `json:"disk_free_bytes"`
DockerVersion string `json:"docker_version"`
// Services lists every service on this node and its state.
Services []proto.ServiceState `json:"services"`
// SFTPPort is where the built-in SFTP server listens (0 = disabled).
SFTPPort int `json:"sftp_port"`
// Web is the node's web hosting stack (nil when Caddy is not installed).
Web *proto.WebCapabilities `json:"web,omitempty"`
// Websites lists the websites this node knows.
Websites []string `json:"websites,omitempty"`
}
Hello is sent first on every connection.
type Link ¶
type Link struct {
URL string
TLS *tls.Config
Hello func(ctx context.Context) Hello // called before every connection
Logger *slog.Logger
// Backoff bounds; zero values use 1s and 60s.
MinBackoff, MaxBackoff time.Duration
// OnConnected is called after each successful handshake (optional, for tests).
OnConnected func()
// Handle answers a panel request; the result becomes the "ok" reply's data. Optional.
Handle func(ctx context.Context, msg Message) (any, error)
// contains filtered or unexported fields
}
Link is a reconnecting connection to the panel.
func (*Link) Notify ¶
Notify sends an event to the panel if connected. Events sent while disconnected are dropped: the next hello carries the current state of everything.