question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IP ranges do not round trip correctly as strings

See original GitHub issue

We are seeing this:

const cidr = "1.2.3.4/5";
IPv4CidrRange.fromCidr(cidr).toCidrString();

// -> 0.0.0.0/5

The CIDR we put in (“1.2.3.4/5”) is not the CIDR we get out (“0.0.0.0/5”)

I can see roughly why this is happening, as /5 is a very big range.

The problem for us is that 1.2.3.4/5 is used as an internal placeholder in CDK: https://github.com/aws/aws-cdk/blob/cea1039e3664fdfa89c6f00cdaeb1a0185a12678/packages/%40aws-cdk/aws-ec2/lib/vpc.ts#L2198

We are seeing tests break when we render our templates and try and round trip things.

What would “you expect to happen” if you put string into a CIDR, then call toCidrString on it? I would say it should be the same, but I am sure there are some optimisations going on internally that are causing this.

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dadepocommented, Dec 2, 2022

Should now be fixed in v1.5.0

1reaction
hlascellescommented, Dec 2, 2022

Terrific thank you. Thanks for this package, it’s very useful!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Program to generate all possible valid IP addresses from ...
Generate all the possible combinations using looping through the string. If IP is found to be valid then return the IP address, ...
Read more >
How to sort IP addresses stored in dictionary in Python?
You can use a custom key function to return a sortable representation of your strings: def split_ip(ip): """Split a IP address given as...
Read more >
Learn IP Address Concepts With Python's ipaddress Module
In this step-by-step tutorial, you'll learn how to inspect and manipulate IP addresses as Python objects with Python's ipaddress module, improving your ...
Read more >
AWS IP address ranges - AWS General Reference
Lists the IP address ranges for AWS.
Read more >
TCP/IP and NBT configuration parameters for Windows XP
The base timeout value is dynamically determined by the measured round-trip time on the connection. TcpNumConnections. Key: Tcpip\Parameters ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found