nodejs / node

Node.js JavaScript runtime ✨🐢🚀✨
https://nodejs.org
Other
104.76k stars 28.3k forks source link

net.normalizeIPv4 and net.normalizeIPv6 #52942

Open RedYetiDev opened 1 month ago

RedYetiDev commented 1 month ago

IP addresses come in various formats, such as dotted decimal notation (X.X.X.X) for IPv4 and hexadecimal notation for IPv6. However, they can also be represented as integers, leading to ambiguity and inconsistency.

For instance:

I propose implementing a function to normalize IP addresses to the X.X.X.X format for IPv4 (and the equivalent format for IPv6), ensuring consistency and ease of use.

net.normalizeIPv4(3232235777); // Returns '192.168.1.1'