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

headscale

package
v0.1.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0, AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package headscale wraps the Headscale v0.29 gRPC API with the narrow set of calls Headmesh needs.

Production cell agents dial Headscale's local unix socket, which Headscale trusts without an API key, so no all-powerful Headscale API key ever leaves the cell host. DialRemote exists only for the approval-gated fallback described in the plan (§9.4).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API interface {
	ListNodes(ctx context.Context) ([]*headscalev1.Node, error)
	CreatePreAuthKey(ctx context.Context, req PreAuthKeyRequest) (*headscalev1.PreAuthKey, error)
	SetTags(ctx context.Context, nodeID uint64, tags []string) (*headscalev1.Node, error)
	RenameNode(ctx context.Context, nodeID uint64, name string) (*headscalev1.Node, error)
	DeleteNode(ctx context.Context, nodeID uint64) error
	ExpireNode(ctx context.Context, nodeID uint64, disableExpiry bool) (*headscalev1.Node, error)
	SetApprovedRoutes(ctx context.Context, nodeID uint64, routes []string) (*headscalev1.Node, error)
	GetPolicy(ctx context.Context) (string, error)
	SetPolicy(ctx context.Context, hujson string) error
	CheckPolicy(ctx context.Context, hujson string) error
	Health(ctx context.Context) error
}

API is the subset of Headscale used by Headmesh. Client implements it; tests use fakes.

type Client

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

Client is a Headscale gRPC client.

func DialRemote

func DialRemote(target, apiKey string, tlsConfig *tls.Config) (*Client, error)

DialRemote connects to a remote Headscale gRPC endpoint over TLS with an API key. Headscale API keys have full admin rights; use only with Aaryn's approval, behind a firewall rule that admits only the Headmesh server.

func DialUnix

func DialUnix(socketPath string) (*Client, error)

DialUnix connects to Headscale's local unix socket (default /var/run/headscale/headscale.sock).

func (*Client) CheckPolicy

func (c *Client) CheckPolicy(ctx context.Context, hujson string) error

func (*Client) Close

func (c *Client) Close() error

Close releases the connection.

func (*Client) CreatePreAuthKey

func (c *Client) CreatePreAuthKey(ctx context.Context, req PreAuthKeyRequest) (*headscalev1.PreAuthKey, error)

func (*Client) DeleteNode

func (c *Client) DeleteNode(ctx context.Context, nodeID uint64) error

func (*Client) ExpireNode

func (c *Client) ExpireNode(ctx context.Context, nodeID uint64, disableExpiry bool) (*headscalev1.Node, error)

func (*Client) GetPolicy

func (c *Client) GetPolicy(ctx context.Context) (string, error)

func (*Client) Health

func (c *Client) Health(ctx context.Context) error

func (*Client) ListNodes

func (c *Client) ListNodes(ctx context.Context) ([]*headscalev1.Node, error)

func (*Client) RenameNode

func (c *Client) RenameNode(ctx context.Context, nodeID uint64, name string) (*headscalev1.Node, error)

func (*Client) SetApprovedRoutes

func (c *Client) SetApprovedRoutes(ctx context.Context, nodeID uint64, routes []string) (*headscalev1.Node, error)

func (*Client) SetPolicy

func (c *Client) SetPolicy(ctx context.Context, hujson string) error

func (*Client) SetTags

func (c *Client) SetTags(ctx context.Context, nodeID uint64, tags []string) (*headscalev1.Node, error)

type PreAuthKeyRequest

type PreAuthKeyRequest struct {
	Tags       []string
	Reusable   bool
	Ephemeral  bool
	Expiration time.Time
}

PreAuthKeyRequest describes a pre-auth key. Headmesh always mints tagged keys without a user, so enrolled nodes are tagged (owned by tagged-devices) and never expire.

Jump to

Keyboard shortcuts

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