Class ACMLocalIps


  • public class ACMLocalIps
    extends java.lang.Object
    ACMLocalIps provides an efficient way to check if an ip address is a local ip address. This is different from a localhost, which specifically is the loopback (127.0.0.1) address. Rather, it is any ip address that is on a local ip card.

    Normally a call to NetworkInterface.getByInetAddress() can be made. But that method is terribly inefficient!
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  ACMLocalIps.IP_FORMAT  
    • Constructor Summary

      Constructors 
      Constructor Description
      ACMLocalIps()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static ACMLocalIps.IP_FORMAT checkIPAddressFormat​(java.lang.String iIpAddress)
      getIPAddressFormat checks if iIpAddress is actually an ip address.
      static boolean isLocalhostByNameOrIP​(java.lang.String hostName)  
      static java.util.Optional<java.lang.Boolean> isLocalIp​(java.lang.String iIpAddress)
      isLocalIp returns true if the input IP address corresponds to any local ip address (hosted by a network card locally).

      This does not do a DNS lookup.
      static boolean isLocalIp​(java.net.InetAddress iInetAddress)
      isLocalIp returns true is the input IP address corresponds to any local ip address (hosted by a network card locally).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ACMLocalIps

        public ACMLocalIps()
    • Method Detail

      • isLocalhostByNameOrIP

        public static boolean isLocalhostByNameOrIP​(java.lang.String hostName)
      • isLocalIp

        public static java.util.Optional<java.lang.Boolean> isLocalIp​(java.lang.String iIpAddress)
        isLocalIp returns true if the input IP address corresponds to any local ip address (hosted by a network card locally).

        This does not do a DNS lookup.
        Parameters:
        iIpAddress -
        Returns:
        true if the address is a local host
      • checkIPAddressFormat

        public static ACMLocalIps.IP_FORMAT checkIPAddressFormat​(java.lang.String iIpAddress)
        getIPAddressFormat checks if iIpAddress is actually an ip address. It checks both ip4 address format and ip6 address format
        Parameters:
        iIpAddress -
        Returns:
        IP_FORMAT.IPV4 or IP_FORMAT.IPV6 if iIpAddress is an ip address, otherwise throws MSTRWebAPIException
        Throws:
        MSTRWebAPIException - when the format of iIpAddress is invalid
      • isLocalIp

        public static boolean isLocalIp​(java.net.InetAddress iInetAddress)
        isLocalIp returns true is the input IP address corresponds to any local ip address (hosted by a network card locally).
        Parameters:
        iIpAddress -
        Returns: