Documentation
¶
Index ¶
- Constants
- type CurlOption
- type Option
- func WithAcceptRoutes() Option
- func WithBuildTag(tag string) Option
- func WithCACert(cert []byte) Option
- func WithDockerEntrypoint(args []string) Option
- func WithDockerWorkdir(dir string) Option
- func WithExtraCommands(commands ...string) Option
- func WithExtraHosts(hosts []string) Option
- func WithExtraLoginArgs(args []string) Option
- func WithHeadscaleName(hsName string) Option
- func WithNetfilter(state string) Option
- func WithNetwork(network *dockertest.Network) Option
- func WithPackages(packages ...string) Option
- func WithSSH() Option
- func WithTags(tags []string) Option
- func WithWebserver(port int) Option
- func WithWebsocketDERP(enabled bool) Option
- type PingOption
- type TailscaleInContainer
- func (t *TailscaleInContainer) ContainerID() string
- func (t *TailscaleInContainer) Curl(url string, opts ...CurlOption) (string, error)
- func (t *TailscaleInContainer) CurlFailFast(url string) (string, error)
- func (t *TailscaleInContainer) DebugDERPRegion(region string) (*ipnstate.DebugDERPRegionReport, error)
- func (t *TailscaleInContainer) Down() error
- func (t *TailscaleInContainer) Execute(command []string, options ...dockertestutil.ExecuteCommandOption) (string, string, error)
- func (t *TailscaleInContainer) FQDN() (string, error)
- func (t *TailscaleInContainer) FailingPeersAsString() (string, bool, error)
- func (t *TailscaleInContainer) GetNodePrivateKey() (*key.NodePrivate, error)
- func (t *TailscaleInContainer) Hostname() string
- func (t *TailscaleInContainer) IPs() ([]netip.Addr, error)
- func (t *TailscaleInContainer) IPv4() (netip.Addr, error)
- func (t *TailscaleInContainer) Login(loginServer, authKey string) error
- func (t *TailscaleInContainer) LoginWithURL(loginServer string) (loginURL *url.URL, err error)
- func (t *TailscaleInContainer) Logout() error
- func (t *TailscaleInContainer) Logs(stdout, stderr io.Writer) error
- func (t *TailscaleInContainer) MustFQDN() string
- func (t *TailscaleInContainer) MustID() types.NodeID
- func (t *TailscaleInContainer) MustIPs() []netip.Addr
- func (t *TailscaleInContainer) MustIPv4() netip.Addr
- func (t *TailscaleInContainer) MustIPv6() netip.Addr
- func (t *TailscaleInContainer) MustStatus() *ipnstate.Status
- func (t *TailscaleInContainer) Netcheck() (*netcheck.Report, error)
- func (t *TailscaleInContainer) Netmap() (*netmap.NetworkMap, error)
- func (t *TailscaleInContainer) PacketFilter() ([]filter.Match, error)
- func (t *TailscaleInContainer) Ping(hostnameOrIP string, opts ...PingOption) error
- func (t *TailscaleInContainer) ReadFile(path string) ([]byte, error)
- func (t *TailscaleInContainer) Restart() error
- func (t *TailscaleInContainer) SaveLog(path string) (string, string, error)
- func (t *TailscaleInContainer) Shutdown() (string, string, error)
- func (t *TailscaleInContainer) Status(save ...bool) (*ipnstate.Status, error)
- func (t *TailscaleInContainer) Traceroute(ip netip.Addr) (util.Traceroute, error)
- func (t *TailscaleInContainer) Up() error
- func (t *TailscaleInContainer) Version() string
- func (t *TailscaleInContainer) WaitForNeedsLogin(timeout time.Duration) error
- func (t *TailscaleInContainer) WaitForPeers(expected int, timeout, retryInterval time.Duration) error
- func (t *TailscaleInContainer) WaitForRunning(timeout time.Duration) error
- func (t *TailscaleInContainer) WriteFile(path string, data []byte) error
- func (t *TailscaleInContainer) WriteLogs(stdout, stderr io.Writer) error
- type TailscaleInContainerBuildConfig
Constants ¶
const (
VersionHead = "head"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CurlOption ¶ added in v0.21.0
type CurlOption = func(args *curlArgs)
CurlOption repreent optional settings that can be given to curl another host.
func WithCurlConnectionTimeout ¶ added in v0.21.0
func WithCurlConnectionTimeout(timeout time.Duration) CurlOption
WithCurlConnectionTimeout sets the timeout for each connection started by curl.
func WithCurlMaxTime ¶ added in v0.21.0
func WithCurlMaxTime(t time.Duration) CurlOption
WithCurlMaxTime sets the max time for a transfer for each connection started by curl.
func WithCurlRetry ¶ added in v0.21.0
func WithCurlRetry(ret int) CurlOption
WithCurlRetry sets the number of retries a connection is attempted by curl.
type Option ¶
type Option = func(c *TailscaleInContainer)
Option represent optional settings that can be given to a Tailscale instance.
func WithAcceptRoutes ¶ added in v0.26.0
func WithAcceptRoutes() Option
WithAcceptRoutes tells the node to accept incoming routes.
func WithBuildTag ¶ added in v0.24.0
WithBuildTag adds an additional value to the `-tags=` parameter of the Go compiler, allowing callers to customize the Tailscale client build. This option is only meaningful when invoked on **HEAD** versions of the client. Attempts to use it with any other version is a bug in the calling code.
func WithCACert ¶ added in v0.24.0
WithCACert adds it to the trusted surtificate of the Tailscale container.
func WithDockerEntrypoint ¶ added in v0.21.0
WithDockerEntrypoint allows the docker entrypoint of the container to be overridden. This is a dangerous option which can make the container not work as intended as a typo might prevent tailscaled and other processes from starting. Use with caution.
func WithDockerWorkdir ¶ added in v0.21.0
WithDockerWorkdir allows the docker working directory to be set.
func WithExtraCommands ¶ added in v0.28.0
WithExtraCommands adds extra shell commands to run before tailscaled starts. Commands are run after package installation and CA certificate updates.
func WithExtraHosts ¶ added in v0.22.2
func WithExtraLoginArgs ¶ added in v0.25.1
WithExtraLoginArgs adds additional arguments to the `tailscale up` command as part of the Login function.
func WithHeadscaleName ¶
WithHeadscaleName set the name of the headscale instance, mostly useful in combination with TLS and WithCACert.
func WithNetfilter ¶ added in v0.23.0
WithNetfilter configures Tailscales parameter --netfilter-mode allowing us to turn of modifying ip[6]tables/nftables. It takes: "on", "off", "nodivert".
func WithNetwork ¶ added in v0.26.0
func WithNetwork(network *dockertest.Network) Option
WithNetwork sets the Docker container network to use with the Tailscale instance.
func WithPackages ¶ added in v0.28.0
WithPackages specifies Alpine packages to install when the container starts. This requires internet access and uses `apk add`. Common packages: - "python3" for HTTP server - "curl" for HTTP client - "bind-tools" for dig command - "iptables", "ip6tables" for firewall rules Note: Tests using this option require internet access and cannot use the built-in DERP server in offline mode.
func WithWebserver ¶ added in v0.28.0
WithWebserver starts a Python HTTP server on the specified port alongside tailscaled. This is useful for testing subnet routing and ACL connectivity. Automatically adds "python3" to packages if needed. The server serves files from the root directory (/).
func WithWebsocketDERP ¶ added in v0.24.0
WithWebsocketDERP toggles a development knob to force enable DERP connection through the new websocket protocol.
type PingOption ¶ added in v0.21.0
type PingOption = func(args *pingArgs)
PingOption represent optional settings that can be given to ping another host.
func WithPingCount ¶ added in v0.21.0
func WithPingCount(count int) PingOption
WithPingCount sets the count of pings to attempt.
func WithPingTimeout ¶ added in v0.21.0
func WithPingTimeout(timeout time.Duration) PingOption
WithPingTimeout sets the timeout for the ping command.
func WithPingUntilDirect ¶ added in v0.21.0
func WithPingUntilDirect(direct bool) PingOption
WithPingUntilDirect decides if the ping should only succeed if a direct connection is established or if successful DERP ping is sufficient.
type TailscaleInContainer ¶
type TailscaleInContainer struct {
// contains filtered or unexported fields
}
TailscaleInContainer is an implementation of TailscaleClient which sets up a Tailscale instance inside a container.
func New ¶
func New( pool *dockertest.Pool, version string, opts ...Option, ) (*TailscaleInContainer, error)
New returns a new TailscaleInContainer instance.
func (*TailscaleInContainer) ContainerID ¶ added in v0.26.0
func (t *TailscaleInContainer) ContainerID() string
ID returns the Docker container ID of the TailscaleInContainer instance.
func (*TailscaleInContainer) Curl ¶ added in v0.21.0
func (t *TailscaleInContainer) Curl(url string, opts ...CurlOption) (string, error)
Curl executes the Tailscale curl command and curls a hostname or IP. It accepts a series of CurlOption.
func (*TailscaleInContainer) CurlFailFast ¶ added in v0.27.0
func (t *TailscaleInContainer) CurlFailFast(url string) (string, error)
CurlFailFast executes the Tailscale curl command with aggressive timeouts optimized for testing expected connection failures. It uses minimal timeouts to quickly detect blocked connections without waiting for multiple retries.
func (*TailscaleInContainer) DebugDERPRegion ¶ added in v0.24.0
func (t *TailscaleInContainer) DebugDERPRegion(region string) (*ipnstate.DebugDERPRegionReport, error)
func (*TailscaleInContainer) Down ¶ added in v0.23.0
func (t *TailscaleInContainer) Down() error
Helper that runs `tailscale down` with no arguments.
func (*TailscaleInContainer) Execute ¶
func (t *TailscaleInContainer) Execute( command []string, options ...dockertestutil.ExecuteCommandOption, ) (string, string, error)
Execute runs a command inside the Tailscale container and returns the result of stdout as a string.
func (*TailscaleInContainer) FQDN ¶
func (t *TailscaleInContainer) FQDN() (string, error)
FQDN returns the FQDN as a string of the Tailscale instance.
func (*TailscaleInContainer) FailingPeersAsString ¶ added in v0.23.0
func (t *TailscaleInContainer) FailingPeersAsString() (string, bool, error)
FailingPeersAsString returns a formatted-ish multi-line-string of peers in the client and a bool indicating if the clients online count and peer count is equal.
func (*TailscaleInContainer) GetNodePrivateKey ¶ added in v0.27.0
func (t *TailscaleInContainer) GetNodePrivateKey() (*key.NodePrivate, error)
func (*TailscaleInContainer) Hostname ¶
func (t *TailscaleInContainer) Hostname() string
Hostname returns the hostname of the Tailscale instance.
func (*TailscaleInContainer) IPs ¶
func (t *TailscaleInContainer) IPs() ([]netip.Addr, error)
IPs returns the netip.Addr of the Tailscale instance.
func (*TailscaleInContainer) IPv4 ¶ added in v0.27.0
func (t *TailscaleInContainer) IPv4() (netip.Addr, error)
IPv4 returns the IPv4 address of the Tailscale instance.
func (*TailscaleInContainer) Login ¶ added in v0.23.0
func (t *TailscaleInContainer) Login( loginServer, authKey string, ) error
Login runs the login routine on the given Tailscale instance. This login mechanism uses the authorised key for authentication.
func (*TailscaleInContainer) LoginWithURL ¶ added in v0.23.0
func (t *TailscaleInContainer) LoginWithURL( loginServer string, ) (loginURL *url.URL, err error)
Up runs the login routine on the given Tailscale instance. This login mechanism uses web + command line flow for authentication.
func (*TailscaleInContainer) Logout ¶ added in v0.18.0
func (t *TailscaleInContainer) Logout() error
Logout runs the logout routine on the given Tailscale instance.
func (*TailscaleInContainer) Logs ¶ added in v0.24.0
func (t *TailscaleInContainer) Logs(stdout, stderr io.Writer) error
Retrieve container logs.
func (*TailscaleInContainer) MustFQDN ¶ added in v0.27.0
func (t *TailscaleInContainer) MustFQDN() string
MustFQDN returns the FQDN as a string of the Tailscale instance, panicking on error.
func (*TailscaleInContainer) MustID ¶ added in v0.26.0
func (t *TailscaleInContainer) MustID() types.NodeID
MustID returns the ID of the Tailscale instance.
func (*TailscaleInContainer) MustIPs ¶ added in v0.26.0
func (t *TailscaleInContainer) MustIPs() []netip.Addr
func (*TailscaleInContainer) MustIPv4 ¶ added in v0.26.0
func (t *TailscaleInContainer) MustIPv4() netip.Addr
func (*TailscaleInContainer) MustIPv6 ¶ added in v0.26.0
func (t *TailscaleInContainer) MustIPv6() netip.Addr
func (*TailscaleInContainer) MustStatus ¶ added in v0.26.0
func (t *TailscaleInContainer) MustStatus() *ipnstate.Status
MustStatus returns the ipnstate.Status of the Tailscale instance.
func (*TailscaleInContainer) Netcheck ¶ added in v0.23.0
func (t *TailscaleInContainer) Netcheck() (*netcheck.Report, error)
Netcheck returns the current Netcheck Report (netcheck.Report) of the Tailscale instance.
func (*TailscaleInContainer) Netmap ¶ added in v0.23.0
func (t *TailscaleInContainer) Netmap() (*netmap.NetworkMap, error)
Netmap returns the current Netmap (netmap.NetworkMap) of the Tailscale instance. Only works with Tailscale 1.56 and newer. Panics if version is lower then minimum.
func (*TailscaleInContainer) PacketFilter ¶ added in v0.27.0
func (t *TailscaleInContainer) PacketFilter() ([]filter.Match, error)
PacketFilter returns the current packet filter rules from the client's network map. This is useful for verifying that policy changes have propagated to the client.
func (*TailscaleInContainer) Ping ¶
func (t *TailscaleInContainer) Ping(hostnameOrIP string, opts ...PingOption) error
Ping executes the Tailscale ping command and pings a hostname or IP. It accepts a series of PingOption. TODO(kradalby): Make multiping, go routine magic.
func (*TailscaleInContainer) ReadFile ¶ added in v0.23.0
func (t *TailscaleInContainer) ReadFile(path string) ([]byte, error)
ReadFile reads a file from the Tailscale container. It returns the content of the file as a byte slice.
func (*TailscaleInContainer) Restart ¶ added in v0.27.1
func (t *TailscaleInContainer) Restart() error
Restart restarts the Tailscale container using Docker API. This simulates a container restart (e.g., docker restart or Kubernetes pod restart). The container's entrypoint will re-execute, which typically includes running "tailscale up" with any auth keys stored in environment variables.
func (*TailscaleInContainer) SaveLog ¶ added in v0.23.0
func (t *TailscaleInContainer) SaveLog(path string) (string, string, error)
SaveLog saves the current stdout log of the container to a path on the host system.
func (*TailscaleInContainer) Shutdown ¶
func (t *TailscaleInContainer) Shutdown() (string, string, error)
Shutdown stops and cleans up the Tailscale container.
func (*TailscaleInContainer) Status ¶
func (t *TailscaleInContainer) Status(save ...bool) (*ipnstate.Status, error)
Status returns the ipnstate.Status of the Tailscale instance.
func (*TailscaleInContainer) Traceroute ¶ added in v0.26.0
func (t *TailscaleInContainer) Traceroute(ip netip.Addr) (util.Traceroute, error)
func (*TailscaleInContainer) Up ¶
func (t *TailscaleInContainer) Up() error
Helper that runs `tailscale up` with no arguments.
func (*TailscaleInContainer) Version ¶
func (t *TailscaleInContainer) Version() string
Version returns the running Tailscale version of the instance.
func (*TailscaleInContainer) WaitForNeedsLogin ¶ added in v0.23.0
func (t *TailscaleInContainer) WaitForNeedsLogin(timeout time.Duration) error
WaitForNeedsLogin blocks until the Tailscale (tailscaled) instance has started and needs to be logged into.
func (*TailscaleInContainer) WaitForPeers ¶
func (t *TailscaleInContainer) WaitForPeers(expected int, timeout, retryInterval time.Duration) error
WaitForPeers blocks until N number of peers is present in the Peer list of the Tailscale instance and is reporting Online.
The method verifies that each peer: - Has the expected peer count - All peers are Online - All peers have a hostname - All peers have a DERP relay assigned
Uses multierr to collect all validation errors.
func (*TailscaleInContainer) WaitForRunning ¶ added in v0.23.0
func (t *TailscaleInContainer) WaitForRunning(timeout time.Duration) error
WaitForRunning blocks until the Tailscale (tailscaled) instance is logged in and ready to be used.
type TailscaleInContainerBuildConfig ¶ added in v0.24.0
type TailscaleInContainerBuildConfig struct {
// contains filtered or unexported fields
}