hsic

package
v0.23.0-beta3.patch5 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: BSD-3-Clause Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultConfigEnv

func DefaultConfigEnv() map[string]string

func MinimumConfigYAML

func MinimumConfigYAML() string

Types

type HeadscaleInContainer

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

HeadscaleInContainer is an implementation of ControlServer which sets up a Headscale instance inside a container.

func New

func New(
	pool *dockertest.Pool,
	network *dockertest.Network,
	opts ...Option,
) (*HeadscaleInContainer, error)

New returns a new HeadscaleInContainer instance.

func (*HeadscaleInContainer) ConnectToNetwork

func (t *HeadscaleInContainer) ConnectToNetwork(network *dockertest.Network) error

func (*HeadscaleInContainer) CreateAuthKey

func (t *HeadscaleInContainer) CreateAuthKey(
	user string,
	reusable bool,
	ephemeral bool,
) (*v1.PreAuthKey, error)

CreateAuthKey creates a new "authorisation key" for a User that can be used to authorise a TailscaleClient with the Headscale instance.

func (*HeadscaleInContainer) CreateUser

func (t *HeadscaleInContainer) CreateUser(
	user string,
) error

CreateUser adds a new user to the Headscale instance.

func (*HeadscaleInContainer) Execute

func (t *HeadscaleInContainer) Execute(
	command []string,
) (string, error)

Execute runs a command inside the Headscale container and returns the result of stdout as a string.

func (*HeadscaleInContainer) FetchPath

func (t *HeadscaleInContainer) FetchPath(path string) ([]byte, error)

FetchPath gets a path from inside the Headscale container and returns a tar file as byte array.

func (*HeadscaleInContainer) GetCert

func (t *HeadscaleInContainer) GetCert() []byte

GetCert returns the public certificate of the HeadscaleInContainer.

func (*HeadscaleInContainer) GetEndpoint

func (t *HeadscaleInContainer) GetEndpoint() string

GetEndpoint returns the Headscale endpoint for the HeadscaleInContainer.

func (*HeadscaleInContainer) GetHealthEndpoint

func (t *HeadscaleInContainer) GetHealthEndpoint() string

GetHealthEndpoint returns a health endpoint for the HeadscaleInContainer instance.

func (*HeadscaleInContainer) GetHostname

func (t *HeadscaleInContainer) GetHostname() string

GetHostname returns the hostname of the HeadscaleInContainer.

func (*HeadscaleInContainer) GetIP

func (t *HeadscaleInContainer) GetIP() string

GetIP returns the docker container IP as a string.

func (*HeadscaleInContainer) GetPort

func (t *HeadscaleInContainer) GetPort() string

GetPort returns the docker container port as a string.

func (*HeadscaleInContainer) ListNodesInUser

func (t *HeadscaleInContainer) ListNodesInUser(
	user string,
) ([]*v1.Node, error)

ListNodesInUser list the TailscaleClients (Node, Headscale internal representation) associated with a user.

func (*HeadscaleInContainer) SaveDatabase

func (t *HeadscaleInContainer) SaveDatabase(savePath string) error

func (*HeadscaleInContainer) SaveLog

func (t *HeadscaleInContainer) SaveLog(path string) error

SaveLog saves the current stdout log of the container to a path on the host system.

func (*HeadscaleInContainer) SaveMapResponses

func (t *HeadscaleInContainer) SaveMapResponses(savePath string) error

func (*HeadscaleInContainer) SaveMetrics

func (t *HeadscaleInContainer) SaveMetrics(savePath string) error

func (*HeadscaleInContainer) SaveProfile

func (t *HeadscaleInContainer) SaveProfile(savePath string) error

func (*HeadscaleInContainer) SendInterrupt

func (t *HeadscaleInContainer) SendInterrupt() error

func (*HeadscaleInContainer) Shutdown

func (t *HeadscaleInContainer) Shutdown() error

Shutdown stops and cleans up the Headscale container.

func (*HeadscaleInContainer) WaitForRunning

func (t *HeadscaleInContainer) WaitForRunning() error

WaitForRunning blocks until the Headscale instance is ready to serve clients.

func (*HeadscaleInContainer) WriteFile

func (t *HeadscaleInContainer) WriteFile(path string, data []byte) error

WriteFile save file inside the Headscale container.

type Option

type Option = func(c *HeadscaleInContainer)

Option represent optional settings that can be given to a Headscale instance.

func WithACLPolicy

func WithACLPolicy(acl *policy.ACLPolicy) Option

WithACLPolicy adds a hscontrol.ACLPolicy policy to the HeadscaleInContainer instance.

func WithConfigEnv

func WithConfigEnv(configEnv map[string]string) Option

WithConfigEnv takes a map of environment variables that can be used to override Headscale configuration.

func WithEmbeddedDERPServerOnly

func WithEmbeddedDERPServerOnly() Option

WithEmbeddedDERPServerOnly configures Headscale to start and only use the embedded DERP server. It requires WithTLS and WithHostnameAsServerURL to be set.

func WithExtraPorts

func WithExtraPorts(ports []string) Option

WithExtraPorts exposes additional ports on the container (e.g. 3478/udp for STUN).

func WithFileInContainer

func WithFileInContainer(path string, contents []byte) Option

WithFileInContainer adds a file to the container at the given path.

func WithHostPortBindings

func WithHostPortBindings(bindings map[string][]string) Option

func WithHostnameAsServerURL

func WithHostnameAsServerURL() Option

WithHostnameAsServerURL sets the Headscale ServerURL based on the Hostname.

func WithIPAllocationStrategy

func WithIPAllocationStrategy(strategy types.IPAllocationStrategy) Option

WithIPAllocationStrategy sets the tests IP Allocation strategy.

func WithPort

func WithPort(port int) Option

WithPort sets the port on where to run Headscale.

func WithPostgres

func WithPostgres() Option

WithPostgres spins up a Postgres container and sets it as the main database.

func WithTLS

func WithTLS() Option

WithTLS creates certificates and enables HTTPS.

func WithTestName

func WithTestName(testName string) Option

WithTestName sets a name for the test, this will be reflected in the Docker container name.

func WithTimezone

func WithTimezone(timezone string) Option

func WithTuning

func WithTuning(batchTimeout time.Duration, mapSessionChanSize int) Option

WithTuning allows changing the tuning settings easily.

Jump to

Keyboard shortcuts

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