cmd/tailscale/cli: don't permit setting self IP as exit node (#1491)

This change makes it impossible to set your own IP address as the exit node for this system.

Fixes #1489

Signed-off-by: Christine Dodrill <xe@tailscale.com>
This commit is contained in:
Christine Dodrill
2021-03-15 15:44:56 -04:00
committed by GitHub
parent ab2a8a7493
commit deff20edc6
2 changed files with 23 additions and 7 deletions
+12
View File
@@ -249,6 +249,18 @@ func runUp(ctx context.Context, args []string) error {
c, bc, ctx, cancel := connect(ctx)
defer cancel()
if !prefs.ExitNodeIP.IsZero() {
st, err := getStatusFromServer(ctx, c, bc)()
if err != nil {
fatalf("can't fetch status from tailscaled: %v", err)
}
for _, ip := range st.TailscaleIPs {
if prefs.ExitNodeIP == ip {
fatalf("cannot use %s as the exit node as it is a local IP address to this machine, did you mean --advertise-exit-node?", ip)
}
}
}
var printed bool
var loginOnce sync.Once
startLoginInteractive := func() { loginOnce.Do(func() { bc.StartLoginInteractive() }) }