Skip to content

Commit

Permalink
Merge pull request #132 from squat/172-16-slash-12
Browse files Browse the repository at this point in the history
pkg/mesh: correctly check 172.16/12 IP range
  • Loading branch information
squat committed Mar 6, 2021
2 parents 90a2540 + 39803ce commit 251e8fa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/mesh/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions pkg/mesh/ip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down

0 comments on commit 251e8fa

Please sign in to comment.