Documentation ¶
Overview ¶
Package web provides the Tailscale client for web.
Index ¶
Constants ¶
View Source
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.)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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.
type ServerMode ¶
type ServerMode string
ServerMode specifies the mode of a running web.Server.
const ( // LoginServerMode serves a readonly login client for logging a // node into a tailnet, and viewing a readonly 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 readonly 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 tailscale.LocalClient to use for this web server. // If nil, a new one will be created. LocalClient *tailscale.LocalClient // 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.
Click to show internal directories.
Click to hide internal directories.