Documentation
¶
Overview ¶
Package remote serves the daemon's API to other devices on the tailnet: the listener setting, device tokens and their scopes, the check every remote call passes, and the launchd or systemd service that keeps the daemon up.
Index ¶
- Constants
- Variables
- func Allows(scopes []Scope) func(procedure string) bool
- func Auth(store *Store, next http.Handler) http.Handler
- func Dir() (string, error)
- func InTailnet(ip netip.Addr) bool
- func Procedures(tok Token) []string
- func Route(api, app http.Handler) http.Handler
- func ScopeList() string
- func TailnetAddr(ifaces func() ([]Iface, error)) (netip.Addr, bool)
- func WriteConfig(dir string, c Config) error
- type Certs
- type Config
- type Iface
- type Listener
- type Runner
- type Scope
- type Service
- func (s *Service) Describe() string
- func (s *Service) Install(ctx context.Context) error
- func (s *Service) InstalledProgram() (string, bool)
- func (s *Service) Path() (string, error)
- func (s *Service) Render() (string, error)
- func (s *Service) Supported() bool
- func (s *Service) Uninstall(ctx context.Context) (bool, error)
- type Store
- type Token
Constants ¶
const ( ServiceLabel = "io.github.amberpixels.f10.daemon" ServiceUnit = "f10-daemon.service" )
ServiceLabel names the launchd agent; ServiceUnit the systemd user unit.
const DefaultPort = 7410
DefaultPort is the listener's port when the setting names none.
const MCPPath = "/mcp"
MCPPath is where the listener serves the API as MCP tools while the setting has MCP on.
Variables ¶
var ErrNoService = errors.New("f10 remote install supports macOS (launchd) and Linux (systemd)")
ErrNoService is a platform with neither launchd nor systemd.
var Scopes = []Scope{ScopeRead, ScopeAnswer, ScopeSteer, ScopeStart, ScopeFinish}
Scopes is every scope, in the order help lists them.
var ServiceEnv = []string{"PATH", "HOME", "F10_RUN_DIR", "XDG_RUNTIME_DIR", "F10_USER_DIR"}
ServiceEnv is the environment the service carries from the shell that installed it: launchd starts a process with almost none, and without these the daemon would land in another run dir and find none of the user's tools.
Functions ¶
func Allows ¶
Allows reports whether scopes reach a procedure as an operation: placed in the table under one of them. Socket-only procedures and those any token may call (Hello) are plumbing, so never allowed here.
func Auth ¶
Auth refuses every remote call that does not carry a valid token with the scope its procedure needs, before any handler runs. It writes Connect errors, so a Connect client reads the refusal as one.
func Dir ¶
Dir holds the setting and the tokens. It lives in the user's f10 dir, not the run dir, because the run dir may be a tmpfs a reboot empties.
func Procedures ¶
Procedures is every procedure tok may call on the tailnet, sorted, so a client hides what it cannot call without a scope table of its own.
func Route ¶
Route sends every Connect procedure to api, a GET or HEAD of anything else to app, and refuses the rest.
func TailnetAddr ¶
TailnetAddr is this machine's Tailscale IPv4 address, read from its interfaces, so no tailscale CLI is needed; false when Tailscale is down.
func WriteConfig ¶
WriteConfig replaces the setting in dir.
Types ¶
type Certs ¶
type Certs struct {
Dir string
Run Runner // exec by default
CLI func() string // the tailscale CLI's path, "" for none
Now func() time.Time // time.Now by default
Wait bool // fetch in the caller, for tests
// contains filtered or unexported fields
}
Certs is the machine's Tailscale HTTPS certificate, fetched with the tailscale CLI into Dir and renewed in the background before it expires.
type Config ¶
type Config struct {
Enabled bool `json:"enabled"`
Port int `json:"port,omitempty"`
// MCP serves the API as MCP tools at MCPPath on the listener.
MCP bool `json:"mcp,omitempty"`
}
A Config is the listener setting: off unless enabled.
func ReadConfig ¶
ReadConfig is the setting in dir; a missing file reads as off.
func (Config) ListenPort ¶
ListenPort is the port the listener binds.
type Iface ¶
An Iface is one network interface that is up, with its addresses.
func Interfaces ¶
Interfaces lists the machine's interfaces that are up.
type Listener ¶
type Listener struct {
Dir string // the setting's and the tokens' dir
Ifaces func() ([]Iface, error) // the machine's interfaces; Interfaces by default
Peer func(netip.Addr) bool // the peers accepted; InTailnet by default
App http.Handler // the web client's files, nil for none
Certs *Certs // the HTTPS certificate, nil for plain HTTP
// Version is the daemon's release, reported to MCP clients.
Version string
// contains filtered or unexported fields
}
A Listener is what the daemon asks of the tailnet listener: where to bind, which peers to accept, and the check in front of the API.
func (*Listener) Addr ¶
Addr is the address to bind and whether the setting is on; with no address, the third value says why none is wanted or none can be bound.
func (*Listener) Handler ¶
Handler puts the token check in front of h, and serves the web client's files beside it without one: they hold no data, and the page that asks for the token must load before it has one. While the setting has MCP on, it also serves MCPPath, each request's tools built from its own token.
type Scope ¶
type Scope string
A Scope is what a token lets a device do.
const ( ScopeRead Scope = "read" // status, board, tasks, events, asks and agents ScopeAnswer Scope = "answer" // answer an ask ScopeSteer Scope = "steer" // send text to an agent ScopeStart Scope = "start" // start, drive or cancel one, create a task ScopeFinish Scope = "finish" // finish a task, close its workspace )
The scopes a token can carry.
func ParseScopes ¶
ParseScopes reads `--scope` values, each one name or a comma list.
type Service ¶
type Service struct {
GOOS string
Home string
UID int
Program string // the f10 the service runs
Env []string // KEY=VALUE pairs it carries
Log string // where its output goes
// Run runs launchctl or systemctl.
Run func(ctx context.Context, name string, args ...string) error
// Drain hands the running daemon's drives to the next one before the
// service restarts, so reinstalling never drops them; nil skips it.
Drain func(ctx context.Context) error
}
A Service is the daemon's launchd agent or systemd user unit.
func (*Service) InstalledProgram ¶
InstalledProgram is the program an installed service file runs; "" when the file is missing or names none.
type Store ¶
type Store struct {
Path string
// contains filtered or unexported fields
}
A Store is the tokens file. Verify rereads it only when it changed, so a revoke takes effect on the next call without a restart.
func (*Store) Add ¶
Add issues a token for name with scopes and returns its secret, which is shown once and never stored.