config

package
v0.3.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: AGPL-3.0 Imports: 19 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 config stores what the agent learns when it joins a panel: its identity, where to connect, and the mTLS key material.

Layout (default directory /etc/ammonode):

agent.json      panel URL, node ID, connect URL, server name
tls/node.key    the node's private key (never leaves the node)
tls/node.crt    client certificate signed by the panel CA
tls/ca.crt      the panel CA, the only CA the agent trusts for the panel

Index

Constants

View Source
const DefaultDir = "/etc/ammonode"

DefaultDir is where the agent keeps its configuration.

Variables

View Source
var ErrNotJoined = errors.New("this node has not joined a panel yet; run: ammonode-agent join <panel-url> --token <token>")

ErrNotJoined means agent.json does not exist yet.

Functions

func NewKey

func NewKey() (keyPEM, csrPEM []byte, err error)

NewKey generates the node's private key and a PEM certificate request for it.

func Save

func Save(dir string, c Config, keyPEM, certPEM, caPEM []byte) error

Save writes the configuration and key material atomically with owner-only permissions.

Types

type Config

type Config struct {
	PanelURL   string `json:"panel_url"`
	NodeID     string `json:"node_id"`
	ConnectURL string `json:"connect_url"`
	ServerName string `json:"server_name"`
}

Config is agent.json.

func Join

func Join(ctx context.Context, panelURL, token, dir string) (Config, error)

Join registers this node with a panel using a one-time token and stores the result in dir. The node's private key is generated here and only its certificate request is sent.

func Load

func Load(dir string) (Config, *tls.Config, error)

Load reads agent.json and builds the mTLS client configuration.

type Identity

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

Identity holds the node's current client certificate.

func LoadIdentity

func LoadIdentity(dir string) (*Identity, error)

LoadIdentity returns the node's key pair holder (for certificate renewal).

func (*Identity) NotAfter

func (id *Identity) NotAfter() time.Time

NotAfter is when the current certificate expires.

func (*Identity) Renew

func (id *Identity) Renew(request func(csrPEM string) (string, error)) error

Renew makes a new key, asks the panel to sign it (request returns the certificate PEM) and stores both. The panel keeps accepting the old certificate for a grace period, so a failure here never locks the node out.

Jump to

Keyboard shortcuts

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