cmd/tailscale: also warn about IP forwarding if using CLI set

We warn users about IP forwarding being disabled when using
`--avertise-routes` in `tailscale up`, this adds the same warnings
to `tailscale set`.

Updates tailscale/corp#9968
Signed-off-by: Jenny Zhang <jz@tailscale.com>
pull/10223/merge
Jenny Zhang 1 year ago committed by phirework
parent 18ceb4e1f6
commit d5d84f1a68

@ -135,6 +135,7 @@ func runSet(ctx context.Context, args []string) (retErr error) {
} }
} }
warnOnAdvertiseRouts(ctx, &maskedPrefs.Prefs)
var advertiseExitNodeSet, advertiseRoutesSet bool var advertiseExitNodeSet, advertiseRoutesSet bool
setFlagSet.Visit(func(f *flag.Flag) { setFlagSet.Visit(func(f *flag.Flag) {
updateMaskedPrefsFromUpOrSetFlag(maskedPrefs, f.Name) updateMaskedPrefsFromUpOrSetFlag(maskedPrefs, f.Name)

@ -437,18 +437,7 @@ func runUp(ctx context.Context, cmd string, args []string, upArgs upArgsT) (retE
fatalf("%s", err) fatalf("%s", err)
} }
if len(prefs.AdvertiseRoutes) > 0 || prefs.AppConnector.Advertise { warnOnAdvertiseRouts(ctx, prefs)
// TODO(jwhited): compress CheckIPForwarding and CheckUDPGROForwarding
// into a single HTTP req.
if err := localClient.CheckIPForwarding(ctx); err != nil {
warnf("%v", err)
}
if runtime.GOOS == "linux" {
if err := localClient.CheckUDPGROForwarding(ctx); err != nil {
warnf("%v", err)
}
}
}
curPrefs, err := localClient.GetPrefs(ctx) curPrefs, err := localClient.GetPrefs(ctx)
if err != nil { if err != nil {
@ -1159,3 +1148,18 @@ func resolveAuthKey(ctx context.Context, v, tags string) (string, error) {
} }
return authkey, nil return authkey, nil
} }
func warnOnAdvertiseRouts(ctx context.Context, prefs *ipn.Prefs) {
if len(prefs.AdvertiseRoutes) > 0 || prefs.AppConnector.Advertise {
// TODO(jwhited): compress CheckIPForwarding and CheckUDPGROForwarding
// into a single HTTP req.
if err := localClient.CheckIPForwarding(ctx); err != nil {
warnf("%v", err)
}
if runtime.GOOS == "linux" {
if err := localClient.CheckUDPGROForwarding(ctx); err != nil {
warnf("%v", err)
}
}
}
}

Loading…
Cancel
Save