cmd/tailscale: respect existing web client pref

After running `tailscale web`, only disable the user pref if it was not
already previously set.

Updates tailscale/corp#14335

Signed-off-by: Will Norris <will@tailscale.com>
pull/10119/head
Will Norris 1 year ago committed by Will Norris
parent cb07ed54c6
commit 7e81c83e64

@ -91,14 +91,20 @@ func runWeb(ctx context.Context, args []string) error {
hasPreviewCap := st.Self.HasCap(tailcfg.CapabilityPreviewWebClient) hasPreviewCap := st.Self.HasCap(tailcfg.CapabilityPreviewWebClient)
cliServerMode := web.LegacyServerMode cliServerMode := web.LegacyServerMode
var existingWebClient bool
if prefs, err := localClient.GetPrefs(ctx); err == nil {
existingWebClient = prefs.RunWebClient
}
if hasPreviewCap { if hasPreviewCap {
cliServerMode = web.LoginServerMode cliServerMode = web.LoginServerMode
if !existingWebClient {
// Also start full client in tailscaled. // Also start full client in tailscaled.
log.Printf("starting tailscaled web client at %s:5252\n", st.Self.TailscaleIPs[0]) log.Printf("starting tailscaled web client at %s:5252\n", st.Self.TailscaleIPs[0])
if err := setRunWebClient(ctx, true); err != nil { if err := setRunWebClient(ctx, true); err != nil {
return fmt.Errorf("starting web client in tailscaled: %w", err) return fmt.Errorf("starting web client in tailscaled: %w", err)
} }
} }
}
webServer, err := web.NewServer(web.ServerOpts{ webServer, err := web.NewServer(web.ServerOpts{
Mode: cliServerMode, Mode: cliServerMode,
@ -115,7 +121,7 @@ func runWeb(ctx context.Context, args []string) error {
case <-ctx.Done(): case <-ctx.Done():
// Shutdown the server. // Shutdown the server.
webServer.Shutdown() webServer.Shutdown()
if hasPreviewCap && !webArgs.cgi { if hasPreviewCap && !webArgs.cgi && !existingWebClient {
log.Println("stopping tailscaled web client") log.Println("stopping tailscaled web client")
// When not in cgi mode, shut down the tailscaled // When not in cgi mode, shut down the tailscaled
// web client on cli termination. // web client on cli termination.

Loading…
Cancel
Save