tailscale

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package tailscale sets up tsnet nodes and serves HTTP handlers on them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewServer

func NewServer(hostname, dir, authKey string, opts ...Option) *tsnet.Server

NewServer returns a tsnet server with the given hostname, state directory and auth key, logging through slog. Messages meant for the user (such as login URLs) are logged at info level, and backend chatter at debug level. Empty dir and authKey leave tsnet's defaults in place.

Without WithLogger, it logs through the default logger as it is when NewServer is called, with a component=tailscale attribute.

func Serve

func Serve(ctx context.Context, s Listener, name string, handler http.Handler) error

Serve serves handler over HTTPS on port 443 of s, and redirects plain HTTP on port 80 to the same path at https://name, until ctx is done. name should be the node's full MagicDNS name, as returned by Up, as that's the name on the certificate.

When ctx is done the servers are shut down gracefully, giving in-flight requests a few seconds to finish before their connections are closed. Serve returns nil after a clean shutdown, or the error that stopped it otherwise.

func Up

func Up(ctx context.Context, s Upper) (string, error)

Up brings the node up, waiting for it to log in if it has never joined the tailnet, and returns its full MagicDNS name without the trailing dot.

Types

type Listener

type Listener interface {
	Listen(network, addr string) (net.Listener, error)
	ListenTLS(network, addr string) (net.Listener, error)
}

Listener is the part of tsnet.Server that Serve uses.

type Option added in v0.0.2

type Option func(*serverOptions)

Option configures NewServer.

func WithLogger added in v0.0.2

func WithLogger(logger *slog.Logger) Option

WithLogger logs through logger as given, adding no attributes.

type Upper

type Upper interface {
	Up(ctx context.Context) (*ipnstate.Status, error)
}

Upper is the part of tsnet.Server that Up uses.

Jump to

Keyboard shortcuts

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