ipn: add user pref for running web client

This is not currently exposed as a user-settable preference through
`tailscale up` or `tailscale set`.  Instead, the preference is set when
turning the web client on and off via localapi. In a subsequent commit,
the pref will be used to automatically start the web client on startup
when appropriate.

Updates tailscale/corp#14335

Signed-off-by: Will Norris <will@tailscale.com>
This commit is contained in:
Will Norris
2023-10-26 11:35:41 -07:00
committed by Will Norris
parent dd842d4d37
commit 28ad910840
8 changed files with 58 additions and 0 deletions

View File

@@ -2249,10 +2249,20 @@ func (h *Handler) serveWeb(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
// try to set pref, but ignore errors
_, _ = h.b.EditPrefs(&ipn.MaskedPrefs{
Prefs: ipn.Prefs{RunWebClient: true},
RunWebClientSet: true,
})
w.WriteHeader(http.StatusOK)
return
case "/localapi/v0/web/stop":
h.b.WebShutdown()
// try to set pref, but ignore errors
_, _ = h.b.EditPrefs(&ipn.MaskedPrefs{
Prefs: ipn.Prefs{RunWebClient: false},
RunWebClientSet: true,
})
w.WriteHeader(http.StatusOK)
return
default: