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 naming every node as an exit peer, the host's own node holding the hosts, 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 slice of the node the admission names 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 IDs the map gives its own node and the home node's peer, 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 naming every node as an exit, 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 host 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 three surfaces mount through the configuration's MountHTTPS — the /ts2021 upgrade into the noise channel, the /derp relay, and the /key fetch over plain TLS beside them.
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) Presence ¶ added in v0.0.7
Presence returns a snapshot of every registered host the map handler has observed since the application started, keyed by node key.
func (*App) RemoveHost ¶ added in v0.0.7
RemoveHost releases the host the node key names: its registry entry is deleted under the admission lock — no admission and no binding interleaves with the delete — and its address returns to the allocator. An open map stream for the key closes at its next re-read, as for any vanished registration, and each node drops the peer at its next directory fetch. A key the registry does not hold releases nothing and succeeds.
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
// IA is the founding core's ISD-AS: the node a host lands on when its
// admission names none.
IA addr.IA
// Authorizer gates registrations — the same seam the trust service
// asks at first issuance, asked here with the registration boundary's
// facts — and names the node each admitted host lands on. Nil admits
// no host.
Authorizer enrollauth.AdmissionAuthorizer
// DERP names the relay the netmap advertises beside the coordination
// endpoint's own identity.
DERP DERPConfig
// Resolvers are the DNS resolvers every netmap names for each exit: a
// client resolves through them while it selects any exit. Empty names
// none.
Resolvers []netip.Addr
// StateDir persists the application's own keys: the noise machine key
// and the DERP server's node key.
StateDir string
// MountHTTPS mounts one of the application's surfaces on the node's
// HTTPS server; the server, its listener, and its TLS identity are the
// assembly's.
MountHTTPS func(pattern string, handler http.Handler)
// 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 every 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 toward the host's own node.
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 Presence ¶ added in v0.0.7
type Presence struct {
// Connected reports an open map stream.
Connected bool
// LastSeen is the last map request's arrival, or the last stream's
// close when that came later.
LastSeen time.Time
// Hostname and OS are the client's latest claims about itself, capped
// and stripped of control characters; empty where it claimed none.
Hostname string
OS string
// Exit is the node whose peer the client reports as its selected exit;
// zero where it reports none or a stable ID no node holds.
Exit addr.IA
}
Presence is what the map handler last observed of one registered host: whether a map stream is open, when its last map request arrived or its last stream closed, and the hostname, operating system, and exit that request claimed. It lives in memory: a restart observes each host anew when it next maps.
type Store ¶
type Store interface {
List(ctx context.Context) (wireguard.Directory, error)
PublishHost(ctx context.Context, entry wireguard.HostEntry) error
DeleteHost(ctx context.Context, key wireguard.PublicKey) error
}
Store is the registry the coordination application works on: the core's directory store, read for node entries, written with host entries, and pruned of the hosts the console releases. The store stays the WireGuard application's — this application borrows the view beside it, never the file.