From 942d720a1610cfa314a1c9eddddeaede4951914e Mon Sep 17 00:00:00 2001 From: Sonia Appasamy Date: Thu, 2 Nov 2023 18:32:27 -0400 Subject: [PATCH] cli/web: don't block startup on status req If the status request to check for the preview node cap fails, continue with starting up the legacy client. Updates tailscale/corp#14335 Signed-off-by: Sonia Appasamy --- cmd/tailscale/cli/web.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cmd/tailscale/cli/web.go b/cmd/tailscale/cli/web.go index 909979a45..40630efb1 100644 --- a/cmd/tailscale/cli/web.go +++ b/cmd/tailscale/cli/web.go @@ -13,6 +13,7 @@ import ( "net" "net/http" "net/http/cgi" + "net/netip" "os" "os/signal" "strings" @@ -84,11 +85,13 @@ func runWeb(ctx context.Context, args []string) error { return fmt.Errorf("too many non-flag arguments: %q", args) } + var hasPreviewCap bool + var selfIP netip.Addr st, err := localClient.StatusWithoutPeers(ctx) - if err != nil { - return fmt.Errorf("getting client status: %w", err) + if err == nil && st.Self != nil && len(st.Self.TailscaleIPs) > 0 { + hasPreviewCap = st.Self.HasCap(tailcfg.CapabilityPreviewWebClient) + selfIP = st.Self.TailscaleIPs[0] } - hasPreviewCap := st.Self.HasCap(tailcfg.CapabilityPreviewWebClient) cliServerMode := web.LegacyServerMode var existingWebClient bool @@ -99,7 +102,7 @@ func runWeb(ctx context.Context, args []string) error { cliServerMode = web.LoginServerMode if !existingWebClient { // 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:%d\n", selfIP.String(), web.ListenPort) if err := setRunWebClient(ctx, true); err != nil { return fmt.Errorf("starting web client in tailscaled: %w", err) }