Skip to content

IPv4/v6 compatibility #15

@kc834

Description

@kc834

Hi, I'm not sure if this repo is still maintained. It seems that the WalkMatch method does not support both IPv4 and IPv6. This is unexpected to me since a regular Match works fine. Can this be fixed?

func Test_TrieBug(t *testing.T) {
	ctrl := gomock.NewController(t)
	defer ctrl.Finish()
	trie := critbitgo.NewNet()
	_, ipNet, _ := net.ParseCIDR("160.0.0.0/8")
	_ = trie.Add(ipNet, 4)
	_, ipNet, _ = net.ParseCIDR("a000:0000:0800::/48")
	_ = trie.Add(ipNet, 6)
	_, ipNet, _ = net.ParseCIDR("a000:0000:0800:a0a0:a0a0:a0a0:a0a0:a0a0/128")
	trie.WalkMatch(ipNet, func(ipNet *net.IPNet, i interface{}) bool {
		if ipNet.IP.To4() != nil {
			t.Fatalf("V6 IP matched with V4 IP")
		}
		return true
	})
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions