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:
parent
7cc707f335
commit
39803cef66
@ -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:
|
||||
|
@ -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"),
|
||||
|
Loading…
Reference in New Issue
Block a user