tailscale.comtailscale.com/client/web Index | Files

package web

import "tailscale.com/client/web"

Package web provides the Tailscale client for web.

Index

Constants

const ListenPort = 5252

ListenPort is the static port used for the web client when run inside tailscaled. (5252 are the numbers above the letters "TSTS" on a qwerty keyboard.)

Types

type Server

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

Server is the backend server for a Tailscale web client.

func NewServer

func NewServer(opts ServerOpts) (s *Server, err error)

NewServer constructs a new Tailscale web client server. If err is empty, s is always non-nil. ctx is only required to live the duration of the NewServer call, and not the lifespan of the web server.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP processes all requests for the Tailscale web client.

func (*Server) Shutdown

func (s *Server) Shutdown()

type ServerMode

type ServerMode string

ServerMode specifies the mode of a running web.Server.

const (
	// LoginServerMode serves a read-only login client for logging a
	// node into a tailnet, and viewing a read-only interface of the
	// node's current Tailscale settings.
	//
	// In this mode, API calls are authenticated via platform auth.
	LoginServerMode ServerMode = "login"

	// ReadOnlyServerMode is identical to LoginServerMode,
	// but does not present a login button to switch to manage mode,
	// even if the management client is running and reachable.
	//
	// This is designed for platforms where the device is configured by other means,
	// such as Home Assistant's declarative YAML configuration.
	ReadOnlyServerMode ServerMode = "readonly"

	// ManageServerMode serves a management client for editing tailscale
	// settings of a node.
	//
	// This mode restricts the app to only being assessible over Tailscale,
	// and API calls are authenticated via browser sessions associated with
	// the source's Tailscale identity. If the source browser does not have
	// a valid session, a read-only version of the app is displayed.
	ManageServerMode ServerMode = "manage"
)

type ServerOpts

type ServerOpts struct {
	// Mode specifies the mode of web client being constructed.
	Mode ServerMode

	// CGIMode indicates if the server is running as a CGI script.
	CGIMode bool

	// PathPrefix is the URL prefix added to requests by CGI or reverse proxy.
	PathPrefix string

	// LocalClient is the local.Client to use for this web server.
	// If nil, a new one will be created.
	LocalClient *local.Client

	// TimeNow optionally provides a time function.
	// time.Now is used as default.
	TimeNow func() time.Time

	// Logf optionally provides a logger function.
	// log.Printf is used as default.
	Logf logger.Logf

	// NewAuthURL should be provided as a function that generates
	// a new tailcfg.WebClientAuthResponse.
	// This field is required for ManageServerMode mode.
	NewAuthURL func(ctx context.Context, src tailcfg.NodeID) (*tailcfg.WebClientAuthResponse, error)
	// WaitAuthURL should be provided as a function that blocks until
	// the associated tailcfg.WebClientAuthResponse has been marked
	// as completed.
	// This field is required for ManageServerMode mode.
	WaitAuthURL func(ctx context.Context, id string, src tailcfg.NodeID) (*tailcfg.WebClientAuthResponse, error)
}

ServerOpts contains options for constructing a new Server.

Source Files

assets.go auth.go qnap.go synology.go web.go

Version
v1.84.0 (latest)
Published
May 21, 2025
Platform
linux/amd64
Imports
43 packages
Last checked
1 day ago

Tools for package owners.