ipn{,/ipnlocal}: add ipn.NotifyInitial* flags to WatchIPNBus

To simplify clients getting the initial state when they subscribe.

Change-Id: I2490a5ab2411253717c74265a46a98012b80db82
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2022-11-30 17:39:43 -08:00
committed by Brad Fitzpatrick
parent 197a4f1ae8
commit 8dd1418774
3 changed files with 43 additions and 2 deletions

View File

@@ -133,6 +133,7 @@ var debugCmd = &ffcli.Command{
FlagSet: (func() *flag.FlagSet {
fs := newFlagSet("watch-ipn")
fs.BoolVar(&watchIPNArgs.netmap, "netmap", true, "include netmap in messages")
fs.BoolVar(&watchIPNArgs.initial, "initial", false, "include initial status")
return fs
})(),
},
@@ -318,11 +319,16 @@ func runPrefs(ctx context.Context, args []string) error {
}
var watchIPNArgs struct {
netmap bool
netmap bool
initial bool
}
func runWatchIPN(ctx context.Context, args []string) error {
watcher, err := localClient.WatchIPNBus(ctx, 0)
var mask ipn.NotifyWatchOpt
if watchIPNArgs.initial {
mask = ipn.NotifyInitialState | ipn.NotifyInitialPrefs | ipn.NotifyInitialNetMap
}
watcher, err := localClient.WatchIPNBus(ctx, mask)
if err != nil {
return err
}