From b48842cf4f355853ffb47cb38b99a27ee61a730f Mon Sep 17 00:00:00 2001 From: Tiru Srikantha Date: Fri, 19 Jun 2015 12:20:30 -0700 Subject: [PATCH] Add RFC 6598 private IP range Fixes #1031 by adding 100.64.0.0/10 as a private IP range. --- consul/util.go | 10 +++++++++- consul/util_test.go | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/consul/util.go b/consul/util.go index 6cc7858995..be53afe17c 100644 --- a/consul/util.go +++ b/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 diff --git a/consul/util_test.go b/consul/util_test.go index 5803e95a9b..00b53fe76a 100644 --- a/consul/util_test.go +++ b/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") }