pkg/mesh: correctly check 172.16/12 IP range

Signed-off-by: Lucas Servén Marín <lserven@gmail.com>
This commit is contained in:
Lucas Servén Marín 2021-03-06 00:50:48 +01:00
parent 7cc707f335
commit 39803cef66
No known key found for this signature in database
GPG Key ID: 586FEAF680DA74AD
2 changed files with 6 additions and 1 deletions

View File

@ -47,7 +47,7 @@ func isPublic(ip net.IP) bool {
case ip4[0] == 10:
return false
// Check for 172.16.0.0/12.
case ip4[0] == 172 && ip4[1]&0xf0 != 0:
case ip4[0] == 172 && ip4[1]&0xf0 == 0x10:
return false
// Check for 192.168.0.0/16.
case ip4[0] == 192 && ip4[1] == 168:

View File

@ -154,6 +154,11 @@ func TestIsPublic(t *testing.T) {
ip: net.ParseIP("172.15.255.255"),
out: true,
},
{
name: "above 172.16/12",
ip: net.ParseIP("172.160.255.255"),
out: true,
},
{
name: "192.168/16",
ip: net.ParseIP("192.168.0.0"),