package localapi
import "tailscale.com/ipn/localapi"
Package localapi contains the HTTP server handlers for tailscaled's API server.
Index ¶
- func InUseOtherUserIPNStream(w http.ResponseWriter, r *http.Request, err error) (handled bool)
- func Register(name string, fn LocalAPIHandler)
- func WriteErrorJSON(w http.ResponseWriter, err error)
- type Handler
- func NewHandler(actor ipnauth.Actor, b *ipnlocal.LocalBackend, logf logger.Logf, logID logid.PublicID) *Handler
- func (h *Handler) LocalBackend() *ipnlocal.LocalBackend
- func (h *Handler) Logf(format string, args ...any)
- func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type LocalAPIHandler
Functions ¶
func InUseOtherUserIPNStream ¶
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 ¶
func Register(name string, fn LocalAPIHandler)
Register registers a new LocalAPI handler for the given name.
func WriteErrorJSON ¶
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 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(actor ipnauth.Actor, b *ipnlocal.LocalBackend, logf logger.Logf, logID logid.PublicID) *Handler
NewHandler creates a new LocalAPI HTTP handler. All parameters are required.
func (*Handler) LocalBackend ¶
func (h *Handler) LocalBackend() *ipnlocal.LocalBackend
func (*Handler) Logf ¶
func (*Handler) ServeHTTP ¶
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type LocalAPIHandler ¶
type LocalAPIHandler func(*Handler, http.ResponseWriter, *http.Request)
Source Files ¶
cert.go debugderp.go localapi.go pprof.go
- Version
- v1.84.1 (latest)
- Published
- May 29, 2025
- Platform
- linux/amd64
- Imports
- 61 packages
- Last checked
- 8 hours ago –
Tools for package owners.