mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 00:34:24 -04:00
Fix IPv6 case for CIDR format reverse zones (#4652)
* fix ipv6 case for cidr.Class Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * add check and test case for invalid ipv6 cidr Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * net package is bad at detecting ipv6/ipv4 Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * rename Class -> Split Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
This commit is contained in:
@@ -14,12 +14,13 @@ var tests = []struct {
|
||||
{"10.0.0.0/16", []string{"10.0.0.0/16"}, []string{"0.10.in-addr.arpa."}},
|
||||
{"192.168.1.1/23", []string{"192.168.0.0/24", "192.168.1.0/24"}, []string{"0.168.192.in-addr.arpa.", "1.168.192.in-addr.arpa."}},
|
||||
{"10.129.60.0/22", []string{"10.129.60.0/24", "10.129.61.0/24", "10.129.62.0/24", "10.129.63.0/24"}, []string{"60.129.10.in-addr.arpa.", "61.129.10.in-addr.arpa.", "62.129.10.in-addr.arpa.", "63.129.10.in-addr.arpa."}},
|
||||
{"2001:db8::/31", []string{"2001:db8::/32", "2001:db9::/32"}, []string{"8.b.d.0.1.0.0.2.ip6.arpa.", "9.b.d.0.1.0.0.2.ip6.arpa."}},
|
||||
}
|
||||
|
||||
func TestClass(t *testing.T) {
|
||||
func TestSplit(t *testing.T) {
|
||||
for i, tc := range tests {
|
||||
_, n, _ := net.ParseCIDR(tc.in)
|
||||
nets := Class(n)
|
||||
nets := Split(n)
|
||||
if len(nets) != len(tc.expected) {
|
||||
t.Errorf("Test %d, expected %d subnets, got %d", i, len(tc.expected), len(nets))
|
||||
continue
|
||||
@@ -35,7 +36,7 @@ func TestClass(t *testing.T) {
|
||||
func TestReverse(t *testing.T) {
|
||||
for i, tc := range tests {
|
||||
_, n, _ := net.ParseCIDR(tc.in)
|
||||
nets := Class(n)
|
||||
nets := Split(n)
|
||||
reverse := Reverse(nets)
|
||||
for j := range reverse {
|
||||
if reverse[j] != tc.zones[j] {
|
||||
|
||||
Reference in New Issue
Block a user