Documentation
¶
Index ¶
- Variables
- func AuthMiddleware(srv *Server) func(http.Handler) http.Handler
- func ExecWith(ctx context.Context, vars map[string]string, argv []string) error
- func Install(ctx context.Context, tool client.Tool) error
- func ListAgents(ctx context.Context, srv *Server, opts *client.AgentListOptions) ([]client.Tailkitd, error)
- func ListHosts(ctx context.Context, srv *Server, opts *client.HostListOptions) ([]client.Host, error)
- func ListPeers(ctx context.Context, srv *Server, opts *client.PeerListOptions) ([]client.Peer, error)
- func NewClient(srv *Server) client.TailnetClient
- func PeersFromHosts(hosts []client.Host) []client.Peer
- func Uninstall(name string) error
- type AgentListOptions
- type CPU
- type CallerContextKey
- type CallerIdentity
- type Event
- type Host
- type JobUpdate
- type JournalEntry
- type LogLine
- type Memory
- type Metrics
- type Peer
- type Port
- type PortUpdate
- type Process
- type Server
- func (s *Server) Close() error
- func (s *Server) HTTPClient() *http.Client
- func (s *Server) ListenAndServe(addr string, handler http.Handler) error
- func (s *Server) ListenAndServeTLS(addr string, handler http.Handler) error
- func (s *Server) StreamHTTPClient() *http.Client
- func (s *Server) TLSConfig() *tls.Config
- type ServerConfig
- type Service
- type ServiceCapabilities
- type ServiceListOptions
- type ServiceStatus
- type Tailkitd
Constants ¶
This section is empty.
Variables ¶
var ( ErrConflict = client.ErrConflict )
Functions ¶
func AuthMiddleware ¶
AuthMiddleware authenticates every inbound request via Tailscale's WhoIs API.
func ExecWith ¶
ExecWith injects vars into the environment of a local subprocess and runs it. Vars are set as KEY=VALUE environment variables. The subprocess inherits the current process's environment with the vars overlaid on top.
Secrets exist only in the child process environment and disappear when it exits — they are never written to disk.
Example:
vars, err := tailkit.Node(srv, "vps-1").Vars("myapp", "prod").List(ctx)
err = tailkit.ExecWith(ctx, vars, []string{"/usr/bin/node", "server.js"})
func Install ¶
Install writes a Tool registration file to /etc/tailkitd/tools/{name}.json.
Call Install once at install time and again on every tool upgrade. tailkitd reads this file to populate its tool registry and exec command list. The write is atomic — tailkitd will never read a partially-written file.
Install validates:
- Tool.Name is non-empty and matches [a-zA-Z0-9_-]+
- Tool.Version is non-empty
- Each Command.Name is non-empty
- Each Command.ExecParts is non-empty and ExecParts[0] exists on disk
- Each Command.Timeout is positive
- Each Arg.Pattern (if set) is a valid regular expression
It creates /etc/tailkitd/tools/ if it does not exist.
func ListAgents ¶ added in v0.5.1
func ListAgents(ctx context.Context, srv *Server, opts *client.AgentListOptions) ([]client.Tailkitd, error)
ListAgents returns tailkitd-* sidecar peers, including orphans without a matching host peer.
func ListHosts ¶ added in v0.5.1
func ListHosts(ctx context.Context, srv *Server, opts *client.HostListOptions) ([]client.Host, error)
ListHosts returns hosts classified from Tailscale status by pairing each machine peer with its tailkitd-<hostname> sidecar.
Results do not include operator metadata from tailkitd's /host API. Use Node(...).Host or FleetClient.Hosts for that.
func ListPeers ¶ added in v0.5.1
func ListPeers(ctx context.Context, srv *Server, opts *client.PeerListOptions) ([]client.Peer, error)
ListPeers returns tailnet machine peers from local Tailscale status. tailkitd-* sidecar peers are excluded.
func NewClient ¶ added in v0.5.1
func NewClient(srv *Server) client.TailnetClient
NewClient creates the entry point for all operations on the Tailnet. It initializes the concrete HTTP transport and returns the top-level namespaces.
func PeersFromHosts ¶ added in v0.5.1
PeersFromHosts returns machine peers for a host list. It is the usual input shape for tailkit.Nodes.
Types ¶
type AgentListOptions ¶ added in v0.5.1
type AgentListOptions struct{ ReachableOnly bool }
type CallerContextKey ¶
type CallerContextKey struct{}
CallerContextKey is the exported context key type for CallerIdentity.
type CallerIdentity ¶
type CallerIdentity struct {
Hostname string
TailscaleIP string
UserLogin string
Caps map[string]bool
}
CallerIdentity holds the verified identity of the caller on an inbound request.
func CallerFromContext ¶
func CallerFromContext(ctx context.Context) (CallerIdentity, bool)
CallerFromContext retrieves the CallerIdentity injected by AuthMiddleware.
func (CallerIdentity) HasCap ¶
func (id CallerIdentity) HasCap(cap string) bool
HasCap reports whether the caller was granted the given ACL capability.
type JournalEntry ¶ added in v0.3.4
type JournalEntry = client.JournalEntry
type PortUpdate ¶ added in v0.4.0
type PortUpdate = client.PortUpdate
type Server ¶
type Server struct {
*tsnet.Server
Config ServerConfig
// contains filtered or unexported fields
}
Server is a tailkit-managed tsnet server.
func NewServer ¶
func NewServer(cfg ServerConfig) (*Server, error)
NewServer constructs and starts a tsnet server.
func (*Server) Close ¶ added in v0.4.1
Close shuts down the shared HTTP transport and underlying tsnet server.
func (*Server) HTTPClient ¶ added in v0.4.1
HTTPClient returns the shared HTTP client used for outbound peer requests.
func (*Server) ListenAndServe ¶
ListenAndServe starts a plain HTTP server on the tsnet listener.
func (*Server) ListenAndServeTLS ¶
ListenAndServeTLS starts an HTTPS server on the tsnet listener.
func (*Server) StreamHTTPClient ¶ added in v0.4.2
StreamHTTPClient returns the shared HTTP client used for long-lived streams.
type ServerConfig ¶
type ServerConfig struct {
Hostname string
AuthKey string
StateDir string
Ephemeral bool
PeerCacheTTL time.Duration
ControlURL string
}
ServerConfig holds configuration for a tailkit-managed tsnet server.
type ServiceCapabilities ¶ added in v0.5.1
type ServiceCapabilities = client.ServiceCapabilities
type ServiceListOptions ¶ added in v0.5.1
type ServiceListOptions struct {
}
type ServiceStatus ¶ added in v0.5.1
type ServiceStatus = client.ServiceStatus