Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement - Collections for IPBlock and IP #69

Open
bkuebler opened this issue Jul 18, 2021 · 3 comments
Open

Improvement - Collections for IPBlock and IP #69

bkuebler opened this issue Jul 18, 2021 · 3 comments

Comments

@bkuebler
Copy link
Contributor

Add Classes which are working as Collections at least for IPBlock. These collection could contain one or many IPBlock Objects and could implement same methods like contain(), isIn(), and so on. And additional methods like aggregate() which gives you back a collection of aggregated IPBlocks. Also a method summarize() which gives you back an IPBlock Object where all given IPBlock Objects in a given collection belongs to. All these things I do always by my own classes, but I think this could also fit into this library and will improve them.

@rlanvin
Copy link
Owner

rlanvin commented Jul 18, 2021

Can you give an example? I'm not sure I understand what you want to do (compared to what the lib already offers).

@bkuebler
Copy link
Contributor Author

Okay let me try... The current IPBlock supports contain() isIn() and so on. Now imagine you have a list like an IP Blocklist Many IPs / Subnet prefixes let's say 100 Networks. Now you create for each network an IPBlock so you have now an array of 100 IPBlocks (IPBlockCollection) and you would like to check if each IPBlock contains in the other or vice versa to get an aggregated IPBlock array with only the elements which are not contained in any of the other blocks. This is the method aggregate() for example. The summarize() method give you just one IPBlock back / use the superblock method from IPBlock which contains all IPBlocks from the given array / collection.

It's complex but already a use case which i often use. Maybe I can create a code example which makes this easier to understand.

@rlanvin
Copy link
Owner

rlanvin commented Jul 22, 2021

Let me try to reformulate to see if I understand correctly.

  • You want to be able to group together a set of random IP addresses and blocks, not necessarily continuous, for example in case of an IP blocklist.
  • Then you want to be able to inspect this list and check if an IP is in it
  • aggregate would merge (?) the IP blocks that are continuous together, to optimise (?) the set?
  • summarize would give you the smallest IP block necessary to contain everything that is in this set?

Some code example would definitely be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants