Package org.hpccsystems.commons.network
Class Network
- java.lang.Object
-
- org.hpccsystems.commons.network.Network
-
public class Network extends Object
-
-
Constructor Summary
Constructors Constructor Description Network()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringgetLocalAddress(String interfacename)Provides non-loopback address bound to given NIC name.static StringgetLocalAddress(String interfacename, boolean ipv6)Provides non-loopback address bound to given NIC name.static booleanisLocalAddress(String address)Determines if address provided is considered a local address Uses cached list of all non-loopback addresses bound to all local NICs.
-
-
-
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
-
-