mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
cmd/tailscale/cli: require v4 and v6 default routes to be advertised together.
Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
parent
78338ac029
commit
ab9cccb292
@ -120,6 +120,11 @@ func checkIPForwarding() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
ipv4default = netaddr.MustParseIPPrefix("0.0.0.0/0")
|
||||||
|
ipv6default = netaddr.MustParseIPPrefix("::/0")
|
||||||
|
)
|
||||||
|
|
||||||
func runUp(ctx context.Context, args []string) error {
|
func runUp(ctx context.Context, args []string) error {
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
log.Fatalf("too many non-flag arguments: %q", args)
|
log.Fatalf("too many non-flag arguments: %q", args)
|
||||||
@ -139,6 +144,7 @@ func runUp(ctx context.Context, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var routes []netaddr.IPPrefix
|
var routes []netaddr.IPPrefix
|
||||||
|
var default4, default6 bool
|
||||||
if upArgs.advertiseRoutes != "" {
|
if upArgs.advertiseRoutes != "" {
|
||||||
advroutes := strings.Split(upArgs.advertiseRoutes, ",")
|
advroutes := strings.Split(upArgs.advertiseRoutes, ",")
|
||||||
for _, s := range advroutes {
|
for _, s := range advroutes {
|
||||||
@ -149,8 +155,18 @@ func runUp(ctx context.Context, args []string) error {
|
|||||||
if ipp != ipp.Masked() {
|
if ipp != ipp.Masked() {
|
||||||
fatalf("%s has non-address bits set; expected %s", ipp, ipp.Masked())
|
fatalf("%s has non-address bits set; expected %s", ipp, ipp.Masked())
|
||||||
}
|
}
|
||||||
|
if ipp == ipv4default {
|
||||||
|
default4 = true
|
||||||
|
} else if ipp == ipv6default {
|
||||||
|
default6 = true
|
||||||
|
}
|
||||||
routes = append(routes, ipp)
|
routes = append(routes, ipp)
|
||||||
}
|
}
|
||||||
|
if default4 && !default6 {
|
||||||
|
fatalf("%s advertised without its IPv6 counterpart, please also advertise %s", ipv4default, ipv6default)
|
||||||
|
} else if default6 && !default4 {
|
||||||
|
fatalf("%s advertised without its IPv6 counterpart, please also advertise %s", ipv6default, ipv4default)
|
||||||
|
}
|
||||||
checkIPForwarding()
|
checkIPForwarding()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user