From effee49e45f2eab681626d2c7ffefbd80f028471 Mon Sep 17 00:00:00 2001 From: Matt Layher Date: Wed, 28 Jul 2021 14:30:06 -0400 Subject: [PATCH] net/interfaces: explicitly check netaddr.IP.Is6 in isUsableV6 Signed-off-by: Matt Layher --- net/interfaces/interfaces.go | 2 +- net/interfaces/interfaces_test.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/net/interfaces/interfaces.go b/net/interfaces/interfaces.go index e2ce140f0..5531ebd94 100644 --- a/net/interfaces/interfaces.go +++ b/net/interfaces/interfaces.go @@ -548,7 +548,7 @@ func isUsableV4(ip netaddr.IP) bool { // (fc00::/7) are in some environments used with address translation. func isUsableV6(ip netaddr.IP) bool { return v6Global1.Contains(ip) || - (ip.IsPrivate() && !tsaddr.TailscaleULARange().Contains(ip)) + (ip.Is6() && ip.IsPrivate() && !tsaddr.TailscaleULARange().Contains(ip)) } var ( diff --git a/net/interfaces/interfaces_test.go b/net/interfaces/interfaces_test.go index fb894e8d8..cd7fff204 100644 --- a/net/interfaces/interfaces_test.go +++ b/net/interfaces/interfaces_test.go @@ -58,6 +58,8 @@ func TestIsUsableV6(t *testing.T) { {"zeros", "0000:0000:0000:0000:0000:0000:0000:0000", false}, {"Link Local", "fe80::1", false}, {"Global", "2602::1", true}, + {"IPv4 public", "192.0.2.1", false}, + {"IPv4 private", "192.168.1.1", false}, } for _, test := range tests {