Merge pull request #132 from squat/172-16-slash-12

pkg/mesh: correctly check 172.16/12 IP range
This commit is contained in:
Lucas Servén Marín 2021-03-06 01:06:36 +01:00 committed by GitHub
commit 251e8fac40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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"),