Browse Source

Add RFC 6598 private IP range

Fixes #1031 by adding 100.64.0.0/10 as a private IP range.
pull/1050/head
Tiru Srikantha 10 years ago
parent
commit
b48842cf4f
  1. 10
      consul/util.go
  2. 3
      consul/util_test.go

10
consul/util.go

@ -19,6 +19,7 @@ import (
/*
* Contains an entry for each private block:
* 10.0.0.0/8
* 100.64.0.0/10
* 172.16.0.0/12
* 192.168/16
*/
@ -41,7 +42,8 @@ func (s *serverParts) String() string {
func init() {
// Add each private block
privateBlocks = make([]*net.IPNet, 3)
privateBlocks = make([]*net.IPNet, 4)
_, block, err := net.ParseCIDR("10.0.0.0/8")
if err != nil {
panic(fmt.Sprintf("Bad cidr. Got %v", err))
@ -59,6 +61,12 @@ func init() {
panic(fmt.Sprintf("Bad cidr. Got %v", err))
}
privateBlocks[2] = block
_, block, err = net.ParseCIDR("100.64.0.0/10")
if err != nil {
panic(fmt.Sprintf("Bad cidr. Got %v", err))
}
privateBlocks[3] = block
}
// strContains checks if a list contains a string

3
consul/util_test.go

@ -38,6 +38,9 @@ func TestIsPrivateIP(t *testing.T) {
if !isPrivateIP("10.1.2.3") {
t.Fatalf("bad")
}
if !isPrivateIP("100.115.110.19") {
t.Fatalf("bad")
}
if isPrivateIP("8.8.8.8") {
t.Fatalf("bad")
}

Loading…
Cancel
Save