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

mesh

package
v0.5.8 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 45 Imported by: 0

Documentation

Overview

Package mesh puts this worker on its project's Mainplane Network: tailscale's engine (wireguard-go, magicsock, the DERP client) on a TUN of its own, with its own state, UDP port, and router, so it runs beside a user's own Tailscale. The coordinator and relay are the harness's, reached over WebSocket at its front door URL, which the harness key proves.

Index

Constants

View Source
const (

	// Every long name is one label under it: one wildcard covers them all.
	Domain = "mainplane.net"
)

Names come from a block in the hosts file, which every OS reads before DNS, so no resolver is touched. Other tools' lines stay as they are.

View Source
const Removed = "removed"

Removed marks a mesh directory whose node the harness removed. Its keys stay refused, so they stay too, until an install starts the node anew.

Variables

View Source
var ErrNoWorker = errors.New("this machine is not a worker")

ErrNoWorker is a socket no worker answers: none runs on this machine.

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

func Clean

func Clean() error

Clean removes what a killed worker left: the hosts block, a status socket no worker answers (off Windows, where a named pipe goes with its process), and on Linux and Windows the rule. Uninstall runs it after the worker stops.

func Harness added in v0.4.0

func Harness(name string) (string, netip.Addr, error)

Harness is the key of the harness the worker on this machine follows, and the address of its peer named name, the harness's node, while the map poll is up. A CLI whose harness has that key reaches it there, off the tunnel.

func Joined added in v0.5.0

func Joined() (harness, name string, err error)

Joined is the key of the harness the worker on this machine follows, and its name there, once the harness has registered it and until it removes it. A worker that never joined, as with a revoked token, is an error.

func Long added in v0.5.0

func Long(name, project string) string

Long is the long name of the node name in project.

func Network added in v0.5.0

func Network() (netip.Prefix, error)

Network is the project's /48, from this machine's address on the mesh, for a server that lets in only the mesh.

func Status

func Status() (string, error)

Status is what the worker on this machine says of its node.

Types

type Mesh

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

Mesh is this worker's node.

func Up

func Up(dir, harness, secret, name string) (*Mesh, error)

Up brings the node up with its state in dir: the TUN, then the engine. It registers as name with the join secret on first start; the keys in dir register again with none. It follows the harness with key harness through the pointer and moves its control client when the harness moves. On the harness's own machine, as admin, control is the harness on loopback: no tunnel or pointer. Its relay is still the tunnel's.

func (*Mesh) Close

func (m *Mesh) Close() error

Close leaves the mesh: the status socket, the hosts block go, the router takes its address, route and rule away, and the TUN goes.

func (*Mesh) Logout added in v0.5.0

func (m *Mesh) Logout() error

Logout deletes this node from the harness's registry, so the name is free for the next node from this machine, which has new keys. It waits for follow to end first, which would register the node again; Close follows.

func (*Mesh) Peer

func (m *Mesh) Peer(name string) (netip.Addr, bool)

Peer is the address of the peer named name in the last map, which stays while the coordinator is out of reach.

func (*Mesh) Removed

func (m *Mesh) Removed() <-chan struct{}

Removed is closed once the harness has removed this worker and it has left the mesh.

func (*Mesh) Report added in v0.5.0

func (m *Mesh) Report(f func() string)

Report adds what f says to the end of mainplane status.

func (*Mesh) Reroute added in v0.5.5

func (m *Mesh) Reroute() error

Reroute puts back this node's route and rule if something took them away. The worker calls it when the harness's address is unreachable.

func (*Mesh) Self

func (m *Mesh) Self() netip.Addr

Self is this node's address in the last map.

Jump to

Keyboard shortcuts

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