controlapi

package
v0.0.0-...-473e292 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2025 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ControlApi

type ControlApi interface {
	// CreateKey generates a new auth key for an untrusted, ephemeral, preauthorized device
	CreateKey(ctx context.Context) (*PreauthKey, error)

	// ListDevices returns all devices in the network
	ListDevices(ctx context.Context) ([]Device, error)

	// ApproveExitNode enables the advertised routes for a device, making it an exit node
	ApproveExitNode(ctx context.Context, deviceID string) error

	// DeleteDevice removes a device from the network
	DeleteDevice(ctx context.Context, deviceID string) error
}

ControlApi defines a generic interface for VPN control plane operations

type Device

type Device struct {
	ID               string
	Name             string
	Hostname         string
	Created          time.Time
	LastSeen         time.Time
	IPAddrs          []string
	IsOnline         bool
	Tags             []string
	AdvertisedRoutes []string
}

Device represents a VPN node in the network

type HeadscaleClient

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

HeadscaleClient implements the ControlApi interface for Headscale

func NewHeadscaleClient

func NewHeadscaleClient(serverAddr string, headscaleUrl string, apiKey string, user string) (*HeadscaleClient, error)

NewHeadscaleClient creates a new HeadscaleClient instance

func (*HeadscaleClient) ApproveExitNode

func (c *HeadscaleClient) ApproveExitNode(ctx context.Context, deviceID string) error

ApproveExitNode implements ControlApi.ApproveExitNode

func (*HeadscaleClient) CreateKey

func (c *HeadscaleClient) CreateKey(ctx context.Context) (*PreauthKey, error)

CreateKey implements ControlApi.CreateKey

func (*HeadscaleClient) DeleteDevice

func (c *HeadscaleClient) DeleteDevice(ctx context.Context, deviceID string) error

DeleteDevice implements ControlApi.DeleteDevice

func (*HeadscaleClient) ListDevices

func (c *HeadscaleClient) ListDevices(ctx context.Context) ([]Device, error)

ListDevices implements ControlApi.ListDevices

type PreauthKey

type PreauthKey struct {
	Key        string
	ControlURL string
	Tags       []string
}

func (PreauthKey) GetCLIArgs

func (k PreauthKey) GetCLIArgs() []string

type TailscaleClient

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

TailscaleClient implements the ControlApi interface for Tailscale

func NewTailscaleClient

func NewTailscaleClient(tailnet string, oauthClientId string, oauthSecret string) (*TailscaleClient, error)

NewTailscaleClient creates a new TailscaleClient instance

func (*TailscaleClient) ApproveExitNode

func (c *TailscaleClient) ApproveExitNode(ctx context.Context, deviceID string) error

ApproveExitNode implements ControlApi.ApproveExitNode

func (*TailscaleClient) CreateKey

func (c *TailscaleClient) CreateKey(ctx context.Context) (*PreauthKey, error)

CreateKey implements ControlApi.CreateKey

func (*TailscaleClient) DeleteDevice

func (c *TailscaleClient) DeleteDevice(ctx context.Context, deviceID string) error

DeleteDevice implements ControlApi.DeleteDevice

func (*TailscaleClient) ListDevices

func (c *TailscaleClient) ListDevices(ctx context.Context) ([]Device, error)

ListDevices implements ControlApi.ListDevices

Jump to

Keyboard shortcuts

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