Documentation
¶
Overview ¶
Package dashboard is the one package in abcd that opens a network listener (adr-2610032150581128; spc-2610040741034208): the product thinker's dashboard, reachable only on this computer's own Tailscale addresses, only while someone has started it on purpose, and only by a device Tailscale's own lookup names. TestOnlyTheDashboardOpensAListener holds every other package to opening none.
Step 1 builds the verb's machinery and the gate: the listener on the tailnet addresses, the connection-time identity check (D2), the HTTP hardening, the detached server process and its control (D5), and one fixed page naming the person let in. No page reads the project yet (D7).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RecordRunForTest ¶
RecordRunForTest writes a run file naming process pid as it stands now, so a front door's test can stand a live process in for the server.
func Serve ¶
Serve is the hidden `dashboard serve`: the server process start launches. It refuses unless start's marker is in its environment and both of start's pipes are open (so nothing but start starts the server, P8), reads its configuration from one, listens on the tailnet addresses it names and nothing else, reports on the other that it is listening, and serves until SIGTERM or SIGINT.
func StartLine ¶
func StartLine(r StartResult) string
StartLine is the one line start prints: where to open it, who can, every address it listens on, and how to stop it.
Types ¶
type Launcher ¶
Launcher is how start runs the server process: this binary's hidden serve in production, the test binary in a test.
func DefaultLauncher ¶
DefaultLauncher runs this binary's hidden `dashboard serve`.
type Lookup ¶
Lookup asks who is at a connecting address: Tailscale's own lookup in the server, a spy in a test.
type Refusal ¶
type Refusal struct {
// contains filtered or unexported fields
}
Refusal is a start, stop or serve that did nothing because something it checks first says no. The front door exits 2 on it.
type RunFile ¶
type RunFile struct {
PID int `json:"pid"`
Process processID `json:"process"`
Name string `json:"name"`
Port int `json:"port"`
Addrs []string `json:"addresses"`
Since time.Time `json:"since"`
}
RunFile is what start records about the server it launched.
type SeenDevice ¶
type SeenDevice struct {
Device string `json:"device"`
Person string `json:"person"`
Login string `json:"login"`
First time.Time `json:"first_opened"`
Last time.Time `json:"last_opened"`
}
SeenDevice is one device that opened the dashboard in this run, by the names Tailscale's lookup gave, so the person can see whom to remove from their tailnet (D6).
type StartOptions ¶
type StartOptions struct {
// Home is the person's home directory, holding abcd's home.
Home string
// Root is the checkout the dashboard serves; the server runs in it.
Root string
// Port is the port to listen on.
Port int
// Tailscale is the resolved command.
Tailscale *tailscale.Client
// Launch starts the server process.
Launch Launcher
}
StartOptions is what start needs.
type StartResult ¶
type StartResult struct {
URL string `json:"url"`
Name string `json:"name"`
Port int `json:"port"`
Addrs []string `json:"addresses"`
PID int `json:"pid"`
Line string `json:"line"`
}
StartResult is what start reports.
func Start ¶
func Start(ctx context.Context, opts StartOptions) (StartResult, error)
Start launches the dashboard and returns once a fetch of its own address through the tailnet has answered. It refuses (a *Refusal) when Tailscale is not running or names no tailnet address for this computer, when the port is one Tailscale's own Serve or Funnel configuration names, and when a dashboard already runs on this computer.
type Status ¶
type Status struct {
Running bool `json:"running"`
URL string `json:"url,omitempty"`
Addrs []string `json:"addresses,omitempty"`
Since *time.Time `json:"since,omitempty"`
PID int `json:"pid,omitempty"`
Stale bool `json:"stale,omitempty"`
Devices []SeenDevice `json:"devices"`
}
Status is what the status verb reports.
func ReadStatus ¶
ReadStatus reports whether the dashboard runs, where, since when, and the devices that opened it in this run. It writes nothing: a stale run file is reported, and left for stop or the next start.
type StopResult ¶
type StopResult struct {
// Stopped is set when stop signalled the server and it is gone.
Stopped bool `json:"stopped"`
// Stale is set when a run file named a process that is gone or is no
// longer the server; it was removed and nothing was signalled.
Stale bool `json:"stale"`
URL string `json:"url,omitempty"`
}
StopResult is what stop reports.
func Stop ¶
func Stop(home string) (StopResult, error)
Stop stops the server start launched. It reads the run file, checks that its process is the one start launched (pid, start time and executable, re-read just before the signal), sends it SIGTERM, waits for it to exit and for its addresses to answer nothing, and removes the run file. It never signals by name or pattern, and never signals a process that is not the one recorded.