I recently had to write a component for an application which allows users to inspect an IP address in detail as well as validate the address against various different criteria. I couldn’t find an API which provides this type of functionality in any of the Adobe classes so I wrote my own. I figured someone else may need to do something similar at some point so I am publishing the API under the MIT License.
The IPV4 API allows detailed inspection of an IP version 4 address (IPv4). It provides a robust API which is not available from Adobe at the moment. Usage is simple and straight forward and contains methods which perform the following:
- Determine if the address specified is a valid IP address
- Determine the network class of the specified IP Address
- Determine the network octet of the specified IP Address
- Determine the host octet of the specified IP Address
- Determine if the IP Address is valid for Network assignment
- Determine if the IP Address is within the Class range specified
- Determine if the IP Address is a loopback address.
Below is a simple usage example which performs various operations on a specific IP Address:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | import com.ericfeminella.net.IPV4Inspector; var ip:IPV4Inspector = new IPV4Inspector("23.14.189.200"); trace("Network Class: " + ip.getNetworkClass()); trace("Is valid IP Address: " + ip.isValid()); trace("Network: " + ip.getNetworkOctet()); trace("Host: " + ip.getHostOctet()); trace("Is loopback: " + ip.isLoopback()); trace("Is valid network host: " + ip.isValidNetworkHost()); Outputs: // Network Class: Class A // Is valid IP Address: true // Network: 23 // Host: 14.189.200 // Is loopback: false // Is valid network host: true |
The IPV4 inspector API can be used for inspecting and validating an IP Address. I plan on adding an update which contains methods for dealing with masks and prefix notation as well.