Help us shape the future of Go! Take the 2026 Go Developer Survey

coordinator

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: MIT, BSD-3-Clause Imports: 30 Imported by: 0

Documentation

Overview

Package coordinator is the harness's side of the Tailscale coordination protocol: ts2021, Noise inside a WebSocket at /ts2021, the one upgrade the tunnel passes. A worker registers with its join secret and gets an address in the project's /48 and a name. The harness's own node registers the same way, on loopback, with a secret only this process holds. Then each node long-polls a map of the nodes it may reach and of the relay. The nodes are in nodes.json in the admin dir.

The protocol handling is copied from headscale's hscontrol (see LICENSE) and trimmed to register, map, keepalive, deltas and ephemeral expiry: no database, CLI, OIDC, policy language, DNS, routes, SSH or Taildrop.

Index

Constants

This section is empty.

Variables

View Source
var Prefix = netip.MustParsePrefix("fd7c:9a2e:4b10::/48")

Prefix holds every node's address, prefix::N. It is one random ULA /48, so it meets no LAN and not Tailscale's 100.64/10 or fd7a:115c:a1e0::/48.

Functions

This section is empty.

Types

type Coordinator

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

Coordinator holds the nodes of one project.

func New

func New(dir string, join func(secret, addr string) (bool, error)) (*Coordinator, error)

New loads the Noise key and the nodes from dir, made there the first time. join checks a join secret sent from addr and says whether it makes ephemeral nodes. Each ephemeral node loaded has idle from now to poll again.

func (*Coordinator) Handle

func (c *Coordinator) Handle(mux *http.ServeMux)

Handle serves the Noise key at /key and the protocol at /ts2021 on mux.

func (*Coordinator) Known

func (c *Coordinator) Known(k key.NodePublic) bool

Known is whether k is a registered node's. The relay admits no other.

func (*Coordinator) Listen

func (c *Coordinator) Listen(ctx context.Context, dir, control string, port int) (net.Listener, error)

Listen puts the harness on its own mesh as a node in userspace, no TUN and no root, with its keys in dir so its address holds across restarts. It registers at control, this coordinator on loopback, so it needs neither the tunnel nor a proof, with the secret only this process holds, and is named worker.Harness. The listener takes port on the node's address, which only nodes the coordinator gave keys to can reach. It all closes when ctx ends.

func (*Coordinator) Node

func (c *Coordinator) Node(a netip.Addr) (string, bool)

Node is the name of the registered node at address a.

func (*Coordinator) Public

func (c *Coordinator) Public() key.MachinePublic

Public is the Noise key workers fetch at /key. The harness key vouches for it in /id, because TLS ends at the tunnel.

func (*Coordinator) Relay

func (c *Coordinator) Relay(u string)

Relay puts the relay at the host of the harness's URL u in every node's map.

func (*Coordinator) Remove

func (c *Coordinator) Remove(name string) error

Remove takes the worker named name off the mesh for good. Its poll ends and peers drop it at once. Its next poll finds it no longer authorized, which its worker takes as the word to leave. Its keys stay refused; the same machine joins again only with new keys, as a new install makes.

Jump to

Keyboard shortcuts

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