@ -21,7 +21,6 @@ import (
"github.com/peterbourgon/ff/v3/ffcli"
"github.com/peterbourgon/ff/v3/ffcli"
"tailscale.com/client/web"
"tailscale.com/client/web"
"tailscale.com/ipn"
"tailscale.com/ipn"
"tailscale.com/tailcfg"
"tailscale.com/util/cmpx"
"tailscale.com/util/cmpx"
)
)
@ -85,11 +84,9 @@ func runWeb(ctx context.Context, args []string) error {
return fmt . Errorf ( "too many non-flag arguments: %q" , args )
return fmt . Errorf ( "too many non-flag arguments: %q" , args )
}
}
var hasPreviewCap bool
var selfIP netip . Addr
var selfIP netip . Addr
st , err := localClient . StatusWithoutPeers ( ctx )
st , err := localClient . StatusWithoutPeers ( ctx )
if err == nil && st . Self != nil && len ( st . Self . TailscaleIPs ) > 0 {
if err == nil && st . Self != nil && len ( st . Self . TailscaleIPs ) > 0 {
hasPreviewCap = st . Self . HasCap ( tailcfg . CapabilityPreviewWebClient )
selfIP = st . Self . TailscaleIPs [ 0 ]
selfIP = st . Self . TailscaleIPs [ 0 ]
}
}
@ -98,7 +95,6 @@ func runWeb(ctx context.Context, args []string) error {
if prefs , err := localClient . GetPrefs ( ctx ) ; err == nil {
if prefs , err := localClient . GetPrefs ( ctx ) ; err == nil {
existingWebClient = prefs . RunWebClient
existingWebClient = prefs . RunWebClient
}
}
if hasPreviewCap {
cliServerMode = web . LoginServerMode
cliServerMode = web . LoginServerMode
if ! existingWebClient {
if ! existingWebClient {
// Also start full client in tailscaled.
// Also start full client in tailscaled.
@ -107,7 +103,6 @@ func runWeb(ctx context.Context, args []string) error {
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 ,
@ -124,7 +119,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 && ! existingWebClient {
if ! 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.