headscale

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUserNotFound = errors.New("user not found")

ErrUserNotFound is returned when a user is not found in Headscale

Functions

This section is empty.

Types

type Client

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

Client wraps the Headscale gRPC client

func NewClient

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

NewClient creates a new Headscale client connected via Unix socket

func NewClientWithAPIKey

func NewClientWithAPIKey(serverAddr string, apiKey string) (*Client, error)

NewClientWithAPIKey creates a new Headscale client connected via gRPC service with API key authentication

func (*Client) Close

func (c *Client) Close() error

Close closes the gRPC connection

func (*Client) CreateAPIKey

func (c *Client) CreateAPIKey(ctx context.Context, expiration time.Duration) (string, time.Time, error)

CreateAPIKey creates a new API key with the specified expiration

func (*Client) CreatePreAuthKey

func (c *Client) CreatePreAuthKey(
	ctx context.Context,
	userID uint64,
	reusable bool,
	ephemeral bool,
	expiration time.Duration,
	tags []string,
) (*v1.PreAuthKey, error)

CreatePreAuthKey creates a new preauth key in Headscale

func (*Client) CreateUser

func (c *Client) CreateUser(ctx context.Context, username, displayName, email, pictureURL string) (*v1.User, error)

CreateUser creates a new user in Headscale

func (*Client) DeletePreAuthKey added in v0.3.0

func (c *Client) DeletePreAuthKey(ctx context.Context, id uint64) error

DeletePreAuthKey deletes a preauth key by key ID

func (*Client) DeleteUser

func (c *Client) DeleteUser(ctx context.Context, userID uint64) error

DeleteUser deletes a user from Headscale by ID

func (*Client) ExpireAPIKey

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

ExpireAPIKey expires an existing API key

func (*Client) GetUserByName

func (c *Client) GetUserByName(ctx context.Context, username string) (*v1.User, error)

GetUserByName retrieves a user from Headscale by name

func (*Client) ListAPIKeys

func (c *Client) ListAPIKeys(ctx context.Context) ([]*v1.ApiKey, error)

ListAPIKeys lists all API keys

func (*Client) WaitForReady

func (c *Client) WaitForReady(ctx context.Context, maxRetries int, retryInterval time.Duration) error

WaitForReady waits for Headscale to be ready by attempting to list API keys

Jump to

Keyboard shortcuts

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