ip-address
ip-address copied to clipboard
Address4 support for isLookback()
While it is a common misconception that 127.0.0.1 is the only IPv4 loopback address, the entire 127.0.0.0/8 block is considered loopback. It would be nice if Address4 provided an isLoopback()
method as syntactic sugar for address.isInSubnet(new Address4('127.0.0.0/8'))
.
@elyscape happy to merge a PR for this one if you'd like to add it! (i will implement it eventually if you don't but it could be a few days); you'd add it to lib/ipv4.js
and a corresponding test in test/functionality-v4-test.js
An alternate option would be to implement it similarly to how it's implemented in Address6, by implementing address types. IPv4 has link-local, private, and multicast addresses, and it might be a good idea to provide detection of those.