The new "tailscale up" checks previously didn't protect against
--advertise-exit-node being omitted in the case that
--advertise-routes was also provided. It wasn't done before because
there is no corresponding pref for "--advertise-exit-node"; it's a
helper flag that augments --advertise-routes. But that's an
implementation detail and we can still help users. We just have to
special case that pref and look whether the current routes include
both the v4 and v6 /0 routes.
Fixes#1767
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
want:"'tailscale up' without --reset requires all preferences with changing values to be explicitly mentioned; --advertise-exit-node flag not mentioned but currently advertised routes are an exit node",
name:"advertised_routes_includes_the_0_routes",// but no --advertise-exit-node
flagSet:f("advertise-routes"),
curPrefs:&ipn.Prefs{
ControlURL:ipn.DefaultControlURL,
AdvertiseRoutes:[]netaddr.IPPrefix{
netaddr.MustParseIPPrefix("10.0.42.0/24"),
netaddr.MustParseIPPrefix("0.0.0.0/0"),
netaddr.MustParseIPPrefix("::/0"),
},
},
mp:&ipn.MaskedPrefs{
Prefs:ipn.Prefs{
ControlURL:ipn.DefaultControlURL,
AdvertiseRoutes:[]netaddr.IPPrefix{
netaddr.MustParseIPPrefix("11.1.43.0/24"),
netaddr.MustParseIPPrefix("0.0.0.0/0"),
netaddr.MustParseIPPrefix("::/0"),
},
},
AdvertiseRoutesSet:true,
},
want:"",
},
{
name:"advertised_routes_includes_only_one_0_route",// and no --advertise-exit-node
flagSet:f("advertise-routes"),
curPrefs:&ipn.Prefs{
ControlURL:ipn.DefaultControlURL,
AdvertiseRoutes:[]netaddr.IPPrefix{
netaddr.MustParseIPPrefix("10.0.42.0/24"),
netaddr.MustParseIPPrefix("0.0.0.0/0"),
netaddr.MustParseIPPrefix("::/0"),
},
},
mp:&ipn.MaskedPrefs{
Prefs:ipn.Prefs{
ControlURL:ipn.DefaultControlURL,
AdvertiseRoutes:[]netaddr.IPPrefix{
netaddr.MustParseIPPrefix("11.1.43.0/24"),
netaddr.MustParseIPPrefix("0.0.0.0/0"),
},
},
AdvertiseRoutesSet:true,
},
want:"'tailscale up' without --reset requires all preferences with changing values to be explicitly mentioned; --advertise-exit-node flag not mentioned but currently advertised routes are an exit node",
errs=append(errs,errors.New("'tailscale up' without --reset requires all preferences with changing values to be explicitly mentioned; --advertise-exit-node flag not mentioned but currently advertised routes are an exit node"))