Documentation
¶
Overview ¶
Package localapi contains the HTTP server handlers for tailscaled's API server.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InUseOtherUserIPNStream ¶ added in v1.34.0
InUseOtherUserIPNStream reports whether r is a request for the watch-ipn-bus handler. If so, it writes an ipn.Notify InUseOtherUser message to the user and returns true. Otherwise it returns false, in which case it doesn't write to w.
Unlike the regular watch-ipn-bus handler, this one doesn't block. The caller (in ipnserver.Server) provides the blocking until the connection is no longer in use.
func Register ¶ added in v1.80.0
func Register(name string, fn LocalAPIHandler)
Register registers a new LocalAPI handler for the given name.
func WriteErrorJSON ¶ added in v1.84.0
func WriteErrorJSON(w http.ResponseWriter, err error)
WriteErrorJSON writes a JSON object (with a single "error" string field) to w with the given error. If err is nil, "unexpected nil error" is used for the stringification instead.
Types ¶
type EventError ¶ added in v1.86.0
type EventError struct {
Error string
}
EventError provides the JSON encoding of internal errors from event processing.
type Handler ¶
type Handler struct { // RequiredPassword, if non-empty, forces all HTTP // requests to have HTTP basic auth with this password. // It's used by the sandboxed macOS sameuserproof GUI auth mechanism. RequiredPassword string // PermitRead is whether read-only HTTP handlers are allowed. PermitRead bool // PermitWrite is whether mutating HTTP handlers are allowed. // If PermitWrite is true, everything is allowed. // It effectively means that the user is root or the admin // (operator user). PermitWrite bool // PermitCert is whether the client is additionally granted // cert fetching access. PermitCert bool // Actor is the identity of the client connected to the Handler. Actor ipnauth.Actor // contains filtered or unexported fields }
func NewHandler ¶
func NewHandler(cfg HandlerConfig) *Handler
NewHandler creates a new LocalAPI HTTP handler from the given config.
func (*Handler) LocalBackend ¶ added in v1.80.0
func (h *Handler) LocalBackend() *ipnlocal.LocalBackend
type HandlerConfig ¶ added in v1.88.0
type HandlerConfig struct { Actor ipnauth.Actor Backend *ipnlocal.LocalBackend Logf logger.Logf LogID logid.PublicID EventBus *eventbus.Bus }
HandlerConfig carries the settings for a local API handler. All fields are required.
type LocalAPIHandler ¶ added in v1.80.0
type LocalAPIHandler func(*Handler, http.ResponseWriter, *http.Request)