Closed erikdubbelboer closed 9 years ago
I agree this functionality is useful, but, for many use cases, people need the network along with the result. I am also worried that reusing the same result between callback calls will cause confusion and bugs.
I wonder if this would be better implemented as some sort of iterator where caller controls the lifespan of the result. This would also remove the need to cast the result back to the original type in the callback.
An iterator is actually a good idea and easy to implement. I also have a version that passes the net to the callback. I'll update the pull request when I have some time to fix it nicely.
Sorry it took so long. Please check the new version I just committed. It now uses an iterator and I added a test case.
Thanks! This looks good. I might take a shot at making it process the subnets in order. It should be doable by switching to depth-first traversal.
I made some minor tweaks to this in the traverse branch to traverse in order and also to return the subnet (net.IPNet
) for the record rather than just the first IP.
That looks really good and quite a bit simpler :) You want me to update my pull request or you just merge your branch into master?
Thanks. I'll merge it. I just want to add some additional tests. I'll hopefully get to it this weekend.
Closing as this is in master already.
Add a method to traverse the loaded database. I personally use this to enumerate the database to extract all possible ISP's from it.
If you want I can add a simple example.