Documentation
¶
Overview ¶
Package config reads Agent GM's environment. There is no config file (spec section 15.1), and secrets are read from nowhere but the environment.
Index ¶
Constants ¶
const MinAdminSecretLength = 43
MinAdminSecretLength is spec section 12.1's floor. 43 characters is the length of a base64url-encoded 256-bit value, so a secret generated the documented way (`devbox run gen-secret`) always clears it and a hand-typed passphrase generally does not.
Variables ¶
var ErrFakeNotAllowed = errors.New(
"AGENT_GM_BACKEND=fake also requires AGENT_GM_ALLOW_FAKE=1; " +
"refusing to serve an empty in-memory phone")
ErrFakeNotAllowed is spec section 15.1: AGENT_GM_BACKEND=fake without AGENT_GM_ALLOW_FAKE=1 refuses to start.
Functions ¶
func ParseDuration ¶
ParseDuration accepts an integer plus a unit of s, m, h or d (spec section 11.1). Anything else is a usage error naming the value.
Types ¶
type Config ¶
type Config struct {
// PublicURL is AGENT_GM_PUBLIC_URL: the issuer, the canonical resource,
// and the base of every URL Agent GM hands out. It is NEVER derived from
// the request's Host, so an agent in a sandbox on another machine
// reaches the same origin the tunnel exposes (spec sections 10.3, 12.3).
PublicURL string
// ListenAddr is AGENT_GM_LISTEN_ADDR.
ListenAddr string
// AdminSecret is AGENT_GM_ADMIN_SECRET, the owner bootstrap credential.
// It lives in the environment only and is at least 43 characters; the
// server refuses to start with a shorter one (spec section 12.1).
AdminSecret string
// TrustedProxyCIDRs is AGENT_GM_TRUSTED_PROXY_CIDRS, parsed. An invalid
// value refuses to start: an operator who mistypes the list should find
// out immediately, not discover months later that the trust they
// configured was never in force (spec section 12.3).
TrustedProxyCIDRs []netip.Prefix
// TrustedProxyRaw is the value as given, for the one startup log line
// that reports which mode is in force.
TrustedProxyRaw string
DataDir string
DataKey store.DataKey
Backend Backend
LogLevel string
LogFormat string
UnsafeTrace bool
Chrome string
PairingTimeout time.Duration
DefaultAccount string
StateDir string
}
Config is the environment Agent GM was started with.
func LoadServer ¶
LoadServer is Load plus the variables only the server needs: AGENT_GM_PUBLIC_URL, AGENT_GM_LISTEN_ADDR, AGENT_GM_ADMIN_SECRET and AGENT_GM_TRUSTED_PROXY_CIDRS.
It is separate from Load because `agm` is the same binary and does not hold the admin secret, does not bind a port, and has no public URL of its own -- requiring them of every invocation would make the CLI unusable on a machine that is not also the server (spec sections 11.5, 15.1).
func (Config) ClientSourceMode ¶
ClientSourceMode is what the one startup log line reports (spec section 12.3), so a misconfiguration where every caller collapses to one source is visible from the first line of the log.