Server setup in the app

This commit is contained in:
Ian Gulliver
2026-10-18 22:17:54 -07:00
parent 327aab069d
commit 602e6703b4
16 changed files with 825 additions and 269 deletions
+26
View File
@@ -50,6 +50,32 @@ func serve(ctx context.Context, port int, target string) (string, error) {
return "", fmt.Errorf("tailscale serve --https=%d exited 0 but port %d is not in serve status", port, port)
}
func Problem(ctx context.Context) string {
_, err := os.Stat(cli)
if err != nil {
return "Install the Tailscale app from https://tailscale.com/download/mac and sign in."
}
out, err := run(ctx, "status", "--json", "--peers=false")
if err != nil {
return "Open Tailscale and sign in (" + err.Error() + ")."
}
status := struct {
BackendState string
CertDomains []string
}{}
err = json.Unmarshal(out, &status)
if err != nil {
return "Parse tailscale status: " + err.Error()
}
if status.BackendState != "Running" {
return "Open Tailscale and sign in (it is " + status.BackendState + ")."
}
if len(status.CertDomains) == 0 {
return "Turn on HTTPS Certificates on the DNS page of Tailscale's admin console, https://login.tailscale.com/admin/dns."
}
return ""
}
func Off(ctx context.Context, port int) error {
_, err := run(ctx, "serve", "--https="+strconv.Itoa(port), "off")
return err