veqryn / cidr-ip-trie

Comparable CIDR and IP types, and Trie collections for suffix, prefix, and longest prefix matching
MIT License
42 stars 12 forks source link

IPv6 support #7

Open brandond opened 7 years ago

brandond commented 7 years ago

Hey, I saw that IPv6 support was on your roadmap. I'm attempting to use your library to increase the speed of logstash-filter-cidr, which is currently VERY slow, but does support IPv6. What would it take to add support not just for IPv6, but also generic v4/v6 ip type and trie?

The use case is that the user may provide a list containing both IPv4 and v6 CIDRs to match, and events to be matched may contain addresses of either type as well. We would need to be able to build a trie containing both types, and make queries using address of either type.

Support for IPv4-mapped IPv6 addresses would also be nice (::ffff:192.168.0.0/120 matches 192.168.0.1)

veqryn commented 7 years ago

Hi, and thanks for looking at my library. I would love to get IPv6 support in. From a technical perspective, we'd want to:

I'll be honest, I probably don't have the time to do that myself in short order. I'd be happy though to work with you or some other interested parties to do it.

brandond commented 7 years ago

I'm passable with Java, although certainly not as handy with it as other languages... but I'd be glad to take a whack at it if you're willing to help with the code review.

I think I can muddle my way through the first item. For the second, I'm at a bit of a loss, having no experience implementing tries, compressed or otherwise. You have any pointers to share that might get me started in the right direction?

veqryn commented 7 years ago

Lets take it in smaller steps and get a compatible IPv6 type out first, with a shared interface. For the trie, the compression I am referring to would be not expanding nodes unnecessarily. So for example, if you put a /32 ipv4 cidr into the trie currently, you will end up with 32 nodes in your trie regardless of whether you have other cidrs in the trie or not. If if you only have 1 cidr in the trie, you only need one or a few nodes.

robeden commented 6 years ago

(First, thanks for the library.)

I'm not to the point where I need this yet, but needing it is on our roadmap. So, add me to the list of people who might get to this first.