On Tue, 15 May 2018 17:38:26 -0700 XXX ZZZ <emartinez1...@gmail.com> wrote:
XXX ZZZ writes:
> 
> I'm trying to check an IP against a list of several CIDR ranges, so far the 
> most obvious way to do it seems to parse both the IP and the cidr ranges (
> ParseCIDR) and then do a net.contain() however, if we have more than 1 CIDR 
> we have to loop checking one by one which imho is incredible unefficient + 
> slow if the cidr range is big.
> 
> Is there any more efficient way of achieving this? I have thought on making 
> a map[string]string with all the IPs (within the CIDR) but the amount of 
> required memory for big lists goes up to a few GB.

You can use a radix or patricia tree. Searching reveals
    https://github.com/zmap/go-iptree 
which may do exactly what you are looking for.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to