public abstract class Addresses extends Object
Constructor and Description |
---|
Addresses() |
Modifier and Type | Method and Description |
---|---|
static void |
clearCaches() |
static SortedSet<String> |
getAddresses()
Warning, very slow on Windows, appx.
|
static SortedSet<String> |
getAddresses(boolean includeLocal,
boolean includeIPv6)
Warning: When includeLocal is false,
all returned addresses should be routable, but they are not necessarily
appropriate for external use.
|
static SortedSet<String> |
getAddresses(boolean includeSiteLocal,
boolean includeLoopbackAndWildcard,
boolean includeIPv6)
Warning: When includeSiteLocal and includeLoopbackAndWildcard are false,
all returned addresses should be routable, but they are not necessarily
appropriate for external use.
|
static SortedSet<String> |
getAddresses(boolean includeSiteLocal,
boolean includeLoopbackAndWildcard,
boolean includeIPv6,
boolean includeIPv6Temporary)
Warning: When includeSiteLocal and includeLoopbackAndWildcard are false,
all returned addresses should be routable, but they are not necessarily
appropriate for external use.
|
static SortedSet<String> |
getAllAddresses()
Warning, very slow on Windows, appx.
|
static String |
getAnyAddress()
Warning, very slow on Windows, appx.
|
static byte[] |
getIP(String host)
Caching version of InetAddress.getByName(host).getAddress(), which is slow.
|
static byte[] |
getIP(String host,
boolean preferIPv6)
For literal IP addresses, this is the same as getIP(String).
|
static byte[] |
getIPOnly(String host)
Caching version of InetAddress.getByName(host).getAddress(), which is slow.
|
static List<byte[]> |
getIPs(String host)
For literal IP addresses, this is the same as getIP(String).
|
static int |
getPort(String port)
Convenience method to convert and validate a port String
without throwing an exception.
|
static byte[] |
getYggdrasilAddress()
Warning, very slow on Windows.
|
static boolean |
isConnected()
Do we have any non-loop, non-wildcard IPv4 address at all?
Warning, very slow on Windows, appx.
|
static boolean |
isConnectedIPv6()
Do we have any non-loop, non-wildcard IPv6 address at all?
Warning, very slow on Windows, appx.
|
static boolean |
isDeprecated(Inet6Address addr)
Is this address deprecated?
Should be reliable on Linux.
|
static boolean |
isDynamic(Inet6Address addr)
Is this address dynamic?
Should be reliable on Linux.
|
static boolean |
isIPAddress(String host) |
static boolean |
isIPv4Address(String host) |
static boolean |
isIPv6Address(String host) |
static boolean |
isTemporary(Inet6Address addr)
Is this address temporary?
Should be reliable on Linux.
|
static void |
main(String[] args)
Print out the local addresses
|
static String |
toString(byte[] addr)
Convenience method to convert an IP address to a String
without throwing an exception.
|
static String |
toString(byte[] addr,
int port)
Convenience method to convert an IP address and port to a String
without throwing an exception.
|
static String |
useIPv6TempAddresses() |
public static boolean isConnected()
public static boolean isConnectedIPv6()
public static String getAnyAddress()
public static SortedSet<String> getAddresses()
public static SortedSet<String> getAllAddresses()
public static SortedSet<String> getAddresses(boolean includeLocal, boolean includeIPv6)
includeLocal
- whether to include local addresses
and deprecated IPv6 addressesincludeIPv6
- whether to include IPV6public static SortedSet<String> getAddresses(boolean includeSiteLocal, boolean includeLoopbackAndWildcard, boolean includeIPv6)
includeSiteLocal
- whether to include private like 192.168.x.x
and deprecated IPv6 addressesincludeLoopbackAndWildcard
- whether to include 127.x.x.x and 0.0.0.0includeIPv6
- whether to include IPV6public static SortedSet<String> getAddresses(boolean includeSiteLocal, boolean includeLoopbackAndWildcard, boolean includeIPv6, boolean includeIPv6Temporary)
includeSiteLocal
- whether to include private like 192.168.x.x
and deprecated IPv6 addressesincludeLoopbackAndWildcard
- whether to include 127.x.x.x and 0.0.0.0includeIPv6
- whether to include IPV6includeIPv6Temporary
- whether to include IPV6 temporary addressespublic static byte[] getYggdrasilAddress()
public static String toString(byte[] addr)
public static String toString(byte[] addr, int port)
public static int getPort(String port)
public static byte[] getIP(String host)
host
- DNS or IPv4 or IPv6 address; if null or empty returns nullpublic static byte[] getIPOnly(String host)
host
- literal IPv4 or IPv6 address; if null returns nullpublic static byte[] getIP(String host, boolean preferIPv6)
host
- DNS or IPv4 or IPv6 address; if null returns nullpublic static List<byte[]> getIPs(String host)
host
- DNS or IPv4 or IPv6 address; if null returns nullpublic static boolean isIPv4Address(String host)
public static boolean isIPv6Address(String host)
public static boolean isIPAddress(String host)
public static boolean isDynamic(Inet6Address addr)
addr
- an address of a local interface, as returned from e.g. getAddresses()public static boolean isDeprecated(Inet6Address addr)
addr
- an address of a local interface, as returned from e.g. getAddresses()public static boolean isTemporary(Inet6Address addr)
addr
- an address of a local interface, as returned from e.g. getAddresses()public static void clearCaches()
public static void main(String[] args)
public static String useIPv6TempAddresses()