diff --git a/cmd/tailscale/cli/serve.go b/cmd/tailscale/cli/serve.go index 59518fecc..3921a57a0 100644 --- a/cmd/tailscale/cli/serve.go +++ b/cmd/tailscale/cli/serve.go @@ -40,6 +40,7 @@ serve https: [off] serve tcp: tcp://localhost: [off] serve tls-terminated-tcp: tcp://localhost: [off] serve status [--json] + serve reset `), LongHelp: strings.TrimSpace(` *** BETA; all of this is subject to change *** @@ -87,6 +88,13 @@ EXAMPLES }), UsageFunc: usageFunc, }, + { + Name: "reset", + Exec: e.runServeReset, + ShortHelp: "reset current serve/funnel config", + FlagSet: e.newFlags("serve-reset", nil), + UsageFunc: usageFunc, + }, }, } } @@ -705,3 +713,15 @@ func elipticallyTruncate(s string, max int) string { } return s[:max-3] + "..." } + +// runServeReset clears out the current serve config. +// +// Usage: +// - tailscale serve reset +func (e *serveEnv) runServeReset(ctx context.Context, args []string) error { + if len(args) != 0 { + return flag.ErrHelp + } + sc := new(ipn.ServeConfig) + return e.lc.SetServeConfig(ctx, sc) +} diff --git a/cmd/tailscale/cli/serve_test.go b/cmd/tailscale/cli/serve_test.go index 8031b2b02..2dec06dd7 100644 --- a/cmd/tailscale/cli/serve_test.go +++ b/cmd/tailscale/cli/serve_test.go @@ -224,7 +224,10 @@ func TestServeConfigMutations(t *testing.T) { command: cmd("https:443 bar https://127.0.0.1:8443"), want: nil, // nothing to save }) - add(step{reset: true}) + add(step{ // try resetting using reset command + command: cmd("reset"), + want: &ipn.ServeConfig{}, + }) add(step{ command: cmd("https:443 / https+insecure://127.0.0.1:3001"), want: &ipn.ServeConfig{