silverwind / cidr-tools

Tools to work with IPv4 and IPv6 CIDR
94 stars 10 forks source link

Add option to disable IPv6 address compression to `normalize` #14

Closed evelynhathaway closed 1 year ago

evelynhathaway commented 1 year ago

Some services only support or automatically format compressed syntax as the expanded representation of the IPV6 address. A new feature to disable the compression of zeros in IPv6 would be helpful in those cases.

Compressed, default and current behavior: fdff:1::

Expanded, proposed option: fdff:0001:0000:0000:0000:0000:0000:0000

evelynhathaway commented 1 year ago

As an example for the automatic format use case, say a developer uses cidr-tools to merge their network blocks. They use Terraform to manage a resource with their merged network with their cloud provider.

Without this feature, Terraform will report that their CIDR blocks changed by their cloud provider every time.

silverwind commented 1 year ago

I could see having a separate function to "uncompress", e.g. the opposite of normalize.

evelynhathaway commented 1 year ago

That would also be a great solution! Nice idea

evelynhathaway commented 1 year ago

I notice the logic for compressing the IP for normalize is from silverwind/ip-bigint. Should the uncompression logic live in there?

silverwind commented 1 year ago

Both modules now take a compress option and ip-bigint now also exports a normalizeIp function.