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

agent

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: AGPL-3.0 Imports: 30 Imported by: 0

Documentation

Overview

Package agent runs a mesh node: it enrolls with the coordinator, keeps the WireGuard engine in sync with the netmap and serves the local API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Enroll

func Enroll(ctx context.Context, opts Options) error

Enroll registers the node with the coordinator (if it is not already) and saves its identity, without bringing the mesh up. Service installation uses it so the auth key never has to be stored in service configuration.

func Run

func Run(ctx context.Context, opts Options) error

Run runs the agent until ctx is cancelled or it is told to shut down.

Types

type Options

type Options struct {
	CoordinatorURL string
	// AuthKey enrolls the node if it is not registered yet (or its token was
	// revoked). It may be empty for an already-registered node.
	AuthKey            string
	Hostname           string
	StateDir           string
	ListenPort         uint16
	Interface          string
	AdvertiseEndpoints []netip.AddrPort
	// AdvertisePublicPorts are UDP ports forwarded to this node on a router
	// with a changing public IP; they are advertised with the current public
	// address as STUN reports it.
	AdvertisePublicPorts []uint16
	// Userspace runs WireGuard over an in-process network stack instead of
	// a kernel TUN interface: no root or NET_ADMIN needed, but programs reach
	// the mesh only through the SOCKS5 proxy.
	Userspace bool
	// SOCKS5 is the listen address of the SOCKS5 proxy into the mesh;
	// empty disables it.
	SOCKS5 string
	// AdvertiseRoutes are subnets this node offers to forward to; with
	// AdvertiseExitNode it also offers to forward to the internet. Both need
	// approval (by an admin or the policy) and TUN mode on Linux.
	AdvertiseRoutes   []netip.Prefix
	AdvertiseExitNode bool
	// AcceptRoutes installs other nodes' approved subnet routes.
	AcceptRoutes bool
	// ExitNode names a peer (by name or mesh IP) to send internet traffic
	// through.
	ExitNode string
	// AcceptDNS points the OS resolver at MagicDNS for mesh names and split
	// DNS domains (TUN mode).
	AcceptDNS bool
	Log       *slog.Logger
}

Options configures the agent.

Directories

Path Synopsis
Package controlclient talks to the coordinator's control service.
Package controlclient talks to the coordinator's control service.
Package engine owns the WireGuard device and keeps it in sync with the netmap pushed by the coordinator.
Package engine owns the WireGuard device and keeps it in sync with the netmap pushed by the coordinator.
Package localapi is the agent's local control socket, used by the CLI.
Package localapi is the agent's local control socket, used by the CLI.
Package magicdns is the agent's DNS resolver.
Package magicdns is the agent's DNS resolver.
Package magicsock is a WireGuard conn.Bind that finds the best path to each peer.
Package magicsock is a WireGuard conn.Bind that finds the best path to each peer.
Package netcfg creates the TUN device and configures it at the OS level.
Package netcfg creates the TUN device and configures it at the OS level.
Package pingsvc implements a tiny UDP echo protocol used by `transporter ping` to measure round trips through the mesh without needing raw sockets or root.
Package pingsvc implements a tiny UDP echo protocol used by `transporter ping` to measure round trips through the mesh without needing raw sockets or root.
Package service installs the agent as a system service: a systemd unit on Linux, a launchd daemon on macOS, a Windows service elsewhere.
Package service installs the agent as a system service: a systemd unit on Linux, a launchd daemon on macOS, a Windows service elsewhere.
Package socks5 is a minimal SOCKS5 server (RFC 1928): CONNECT only, no authentication.
Package socks5 is a minimal SOCKS5 server (RFC 1928): CONNECT only, no authentication.
Package state persists the agent's identity between runs.
Package state persists the agent's identity between runs.
Package tundev wraps the TUN device between the OS (or netstack) and WireGuard.
Package tundev wraps the TUN device between the OS (or netstack) and WireGuard.

Jump to

Keyboard shortcuts

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