Documentation
¶
Overview ¶
Package coordination is the coordination application: the network's headscale, minimal by decision, served by the core alone beside the WireGuard application. It speaks the tailnet client protocol from vendored packages — the noise channel inside WebPKI HTTPS on the core's domain, registration behind the generalized admission seam, the netmap holding one peer — the host's node — and the DERP relay a client expects as its fallback path. Hosts are logins, not configuration edits: admission allocates the next free address in the owning node's slice of the tailnet range and records one registry entry that distributes by the directory every node already fetches.
Index ¶
Constants ¶
const ( // Tailnet is the overlay's host space, the range every slice is a // slice of. Tailnet = "100.64.0.0/10" )
The netmap's constants: the tailnet range the tunnel carries and nothing else — no default route is advertised, internet egress stays a service on the overlay — and the one DERP region the core serves.
Variables ¶
This section is empty.
Functions ¶
func LoadOrCreateDERPKey ¶
func LoadOrCreateDERPKey(stateDir string) (key.NodePrivate, error)
LoadOrCreateDERPKey returns the DERP server's node key persisted in the application's state directory, generating and persisting one when no file exists. The key names the relay on the wire; its stability is what keeps connected clients connected across restarts.
func LoadOrCreateMachineKey ¶
func LoadOrCreateMachineKey(stateDir string) (key.MachinePrivate, error)
LoadOrCreateMachineKey returns the noise machine key persisted in the application's state directory, generating and persisting one when no file exists. The key is the server's half of every client's noise channel: a client that re-dials must meet the same key its registration trusted.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is the coordination application: the noise channel of the client protocol carrying registration behind the admission seam, the netmap holding one peer, and the DERP relay fallback — its three surfaces handed to the node's assembly, which serves them over the core's WebPKI identity on the HTTPS port it owns. Minimal by decision: no ACL engine, no naming, no user management, no key expiry, no credential minting, no listener of its own.
func New ¶
New assembles the application: keys load or create in its own state, the DERP server stands on its node key, and the HTTP surface builds — the /ts2021 upgrade into the noise channel, the /derp relay, and the /key fetch over plain TLS beside them. Handler hands the surface to its mounter.
func (*App) Close ¶
func (a *App) Close()
Close retires the application: the served noise conversations and the relay with its connected clients. It marks the application closed, so no conversation starts after it and a relay client's connection closes at once, and closes each open conversation's connection and each relay client's, for their clients may never leave; it returns once the server has finished with each conversation and the relay with each client. A second call releases nothing.
func (*App) HTTPSHandler ¶
HTTPSHandler is the application's HTTP surface — the /key fetch, the /ts2021 upgrade into the noise channel, and the /derp relay — for the assembly's mux to mount. The serving server, the listener, and the TLS identity are the assembly's; the keys, the state, and the conversations stay the application's.
type Config ¶
type Config struct {
// Domain is the core's identity: the name the certificate answers for
// and the tailnet's own.
Domain string
// Store is the registry: node entries read for the netmap and
// allocation, host entries written at admission.
Store Store
// Authorizer gates registrations — the same seam the trust service
// asks at first issuance, asked here with the registration boundary's
// facts. Nil is open admission, the zero-conf default.
Authorizer enrollauth.AdmissionAuthorizer
// DERP names the relay the netmap advertises beside the coordination
// endpoint's own identity.
DERP DERPConfig
// StateDir persists the application's own keys: the noise machine key
// and the DERP server's node key.
StateDir string
// MapResend overrides, for tests, how often an open map stream re-reads
// the registry — the bound on how long a peer change hides from a
// connected host. Zero means the package constant.
MapResend time.Duration
// RelayOnly strips the peer's endpoint from every netmap: the
// integration harness's stand-in for a network where UDP to the node
// cannot pass, forcing the relay leg.
RelayOnly bool
}
Config configures the coordination application.
type DERPConfig ¶
type DERPConfig struct {
// HostName is the DERP node's hostname — the core's identity by
// default, the name the certificate answers for; an address answers
// the resolver and the verification both.
HostName string
// IPv4 optionally dials the relay by address instead of DNS — the
// integration harness's stand-in for resolution.
IPv4 string
// Port overrides the DERP HTTPS port 443; zero is 443.
Port int
// CertName optionally pins the certificate the relay presents, in the
// DERP map's grammar ("sha256-raw:<hex>" among them) — the harness's
// stand-in for the WebPKI.
CertName string
}
DERPConfig names the relay a netmap advertises: the core's own HTTPS identity, one region, the one fallback path a client expects.
type Store ¶
type Store interface {
List(ctx context.Context) (wireguard.Directory, error)
PublishHost(ctx context.Context, entry wireguard.HostEntry) error
}
Store is the registry the coordination application works on: the core's directory store, read for node entries and written with host entries. The store stays the WireGuard application's — this application borrows the view beside it, never the file.