|
Brooklyn | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object brooklyn.util.NetworkUtils
public class NetworkUtils
Field Summary | |
---|---|
static int |
MAX_PORT_NUMBER
|
static int |
MIN_PORT_NUMBER
|
static java.util.List |
PRIVATE_NETWORKS
|
static java.util.regex.Pattern |
VALID_IP_ADDRESS_PATTERN
|
static java.lang.String |
VALID_IP_ADDRESS_REGEX
|
Method Summary | |
---|---|
static int
|
checkPortValid(java.lang.Integer port, java.lang.String errorMessage)
|
static void
|
checkPortsValid(java.util.Map ports)
|
static Cidr
|
cidr(java.lang.String cidr)
returns a CIDR object for the given string, e.g. "10.0.0.0/8" |
static java.lang.String
|
getAddressOfUnresolvableHostname()
returns null in a sane DNS environment, but if DNS provides a bogus address for made-up hostnames, this returns that address |
static java.net.InetAddress
|
getInetAddressWithFixedName(byte[] ip)
Gets an InetAddress using the given IP, and using that IP as the hostname (i.e. avoids any hostname resolution). |
static java.net.InetAddress
|
getInetAddressWithFixedName(java.lang.String hostnameOrIp)
Gets an InetAddress using the given hostname or IP. |
static java.util.Map
|
getLocalAddresses()
returns all local addresses |
static java.net.InetAddress
|
getLocalHost()
returns local IP address, or 127.0.0.1 if it cannot be parsed |
static java.lang.String
|
getLocalhostExternalIp()
returns the externally-facing IP address from which this host comes |
static Cidr
|
getPrivateNetwork(java.lang.String ip)
returns any well-known private network (e.g. 10.0.0.0/8 or 192.168.0.0/16) which the given IP is in, or the /32 of local address if none |
static Cidr
|
getPrivateNetwork(java.net.InetAddress address)
|
static boolean
|
isPortAvailable(int port)
|
static boolean
|
isPortAvailable(java.net.InetAddress localAddress, int port)
|
static boolean
|
isPortValid(java.lang.Integer port)
|
static boolean
|
isPrivateSubnet(java.net.InetAddress address)
Check if this is a private address, not exposed on the public Internet. |
static boolean
|
isPublicIp(java.lang.String ipAddress)
returns whether the IP is _not_ in any private subnet |
static int
|
nextAvailablePort(int port)
returns the first port available on the local machine >= the port supplied |
static java.net.InetAddress
|
resolve(java.lang.String hostname)
resolves the given hostname to an IP address, returning null if unresolvable or if the resolution is bogus (eg 169.* subnet or a "catch-all" IP resolution supplied by some miscreant DNS services) |
Methods inherited from class java.lang.Object | |
---|---|
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Field Detail |
---|
public static final int MAX_PORT_NUMBER
public static final int MIN_PORT_NUMBER
public static final java.util.List PRIVATE_NETWORKS
public static final java.util.regex.Pattern VALID_IP_ADDRESS_PATTERN
public static final java.lang.String VALID_IP_ADDRESS_REGEX
Method Detail |
---|
public static int checkPortValid(java.lang.Integer port, java.lang.String errorMessage)
public static void checkPortsValid(@SuppressWarnings("rawtypes") java.util.Map ports)
public static Cidr cidr(java.lang.String cidr)
public static java.lang.String getAddressOfUnresolvableHostname()
public static java.net.InetAddress getInetAddressWithFixedName(byte[] ip)
This is very useful if using the InetAddress for updating config files on remote machines, because then it will not be pickup a hostname from the local /etc/hosts file, which might not be known on the remote machine.
public static java.net.InetAddress getInetAddressWithFixedName(java.lang.String hostnameOrIp)
public static java.util.Map getLocalAddresses()
public static java.net.InetAddress getLocalHost()
public static java.lang.String getLocalhostExternalIp()
public static Cidr getPrivateNetwork(java.lang.String ip)
public static Cidr getPrivateNetwork(java.net.InetAddress address)
public static boolean isPortAvailable(int port)
public static boolean isPortAvailable(java.net.InetAddress localAddress, int port)
public static boolean isPortValid(java.lang.Integer port)
public static boolean isPrivateSubnet(java.net.InetAddress address)
For IPV6 addresses this is the RFC3514 link local block (fe80::/10) and site local block (feco::/10) or the loopback block (::1/128).
public static boolean isPublicIp(java.lang.String ipAddress)
public static int nextAvailablePort(int port)
public static java.net.InetAddress resolve(java.lang.String hostname)
Brooklyn Multi-Cloud Application Management Platform
brooklyncentral.github.com. Apache License. © 2012.