Open toreanderson opened 1 year ago
I use this:
def remove_prefix(aggregated_tree, prefix):
# simple case: prefix itself or children of it are in the tree
# those can simply be deleted
# this will also include the prefix itself
children = aggregated_tree.search_covered(prefix)
if children:
for child in children:
aggregated_tree.delete(child.prefix)
# complex case: a supernet is contained in the tree
# this has to be split up
parent = aggregated_tree.search_worst(parent)
if parent:
aggregated_tree.delete(parent.prefix)
siblings = ip_network(parent.prefix).address_exclude(ip_network(prefix))
for sibling in siblings:
aggregated_tree.add(str(sibling))
First, you run aggregate for both prefixes.txt, and exceptions.txt, then for all entries in exceptions.txt you run the remove_prefix function on prefixes.txt. Could be integrated into aggregate6, or added as a second script.
In case you're taking feature requests, it would be useful to generate an aggregated prefix list but with some sub-prefixes removed:
Mock-up to explain what I mean:
If on the other hand you're not taking feature requests, feel free to close this issue. In any case, thank you for this very useful tool!