ipn/ipnlocal: start implementing web server bits of serve

Updates tailscale/corp#7515

Change-Id: I96f4016161ba3c370492da941274c6d9a234c2bb
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2022-11-09 06:55:17 -08:00
committed by Brad Fitzpatrick
parent c35dcd427f
commit 25e26c16ee
6 changed files with 119 additions and 40 deletions

View File

@@ -564,7 +564,8 @@ var devStoreSetArgs struct {
func runDevStoreSet(ctx context.Context, args []string) error {
// TODO(bradfitz): remove this temporary (2022-11-09) hack once
// profile stuff and serving CLI commands are more fleshed out.
if len(args) >= 1 && strings.HasPrefix(args[0], "_serve/") {
isServe := len(args) >= 1 && strings.HasPrefix(args[0], "_serve/")
if isServe {
st, err := localClient.StatusWithoutPeers(ctx)
if err != nil {
return err
@@ -584,6 +585,11 @@ func runDevStoreSet(ctx context.Context, args []string) error {
if err != nil {
return err
}
if isServe {
if err := json.Unmarshal(valb, new(ipn.ServeConfig)); err != nil {
return fmt.Errorf("invalid JSON: %w", err)
}
}
val = string(valb)
}
return localClient.SetDevStoreKeyValue(ctx, key, val)