Class Network


  • public class Network
    extends Object
    • Constructor Detail

      • Network

        public Network()
    • Method Detail

      • getLocalAddress

        public static String getLocalAddress​(String interfacename)
                                      throws Exception
        Provides non-loopback address bound to given NIC name.
        Parameters:
        interfacename - - The NIC name to draw the local address from, or '*'
        Returns:
        - Local ipv4 address
        Throws:
        Exception - the exception
      • getLocalAddress

        public static String getLocalAddress​(String interfacename,
                                             boolean ipv6)
                                      throws Exception
        Provides non-loopback address bound to given NIC name.
        Parameters:
        interfacename - - The NIC name to draw the local address from, or '*'
        ipv6 - - True if ipv6 desired, False if ipv4 desired
        Returns:
        the local address
        Throws:
        Exception - the exception
      • isLocalAddress

        public static boolean isLocalAddress​(String address)
        Determines if address provided is considered a local address Uses cached list of all non-loopback addresses bound to all local NICs.
        Parameters:
        address - ipv4/6 to be compared to all known local addresses
        Returns:
        True if address is part of known local addresses False otherwise