public class SshdSocketAddress extends SocketAddress
A simple socket address holding the host name and port number. The reason
it does not extend InetSocketAddress
is twofold:
The InetSocketAddress
performs a DNS resolution on the
provided host name - which we don't want do use until we want to
create a connection using this address (thus the toInetSocketAddress()
call which executes this query
If empty host name is provided we replace it with the any address of 0.0.0.0
Modifier and Type | Field and Description |
---|---|
static String |
BROADCAST_ADDRESS |
static Comparator<InetAddress> |
BY_HOST_ADDRESS
Compares
InetAddress -es according to their InetAddress.getHostAddress()
value case insensitive |
static String |
CARRIER_GRADE_NAT_PREFIX |
static String |
IP_ANYADDR |
static SshdSocketAddress |
LOCALHOST_ADDRESS
A dummy placeholder that can be used instead of
null s |
static String |
LOCALHOST_IP |
static String |
LOCALHOST_NAME |
static String |
PRIVATE_CLASS_A_PREFIX |
static String |
PRIVATE_CLASS_B_PREFIX |
static String |
PRIVATE_CLASS_C_PREFIX |
Constructor and Description |
---|
SshdSocketAddress(int port) |
SshdSocketAddress(String hostName,
int port) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
static List<InetAddress> |
getExternalNetwork4Addresses() |
static InetAddress |
getFirstExternalNetwork4Address()
Returns the first external network address assigned to this
machine or null if one is not found.
|
String |
getHostName() |
int |
getPort() |
int |
hashCode() |
static boolean |
isCarrierGradeNatIPv4Address(String addr) |
protected boolean |
isEquivalent(SshdSocketAddress that) |
static boolean |
isIPv4Address(String addr) |
static boolean |
isLoopback(InetAddress addr) |
static boolean |
isLoopback(String ip) |
static boolean |
isPrivateIPv4Address(String addr)
Checks if the address is one of the allocated private blocks
|
static boolean |
isValidHostAddress(InetAddress addr) |
static boolean |
isValidIPv4AddressComponent(CharSequence c)
Checks if the provided argument is a valid IPv4 address component:
|
static String |
toAddressString(InetAddress addr) |
InetSocketAddress |
toInetSocketAddress() |
String |
toString() |
public static final String LOCALHOST_NAME
public static final String LOCALHOST_IP
public static final String IP_ANYADDR
public static final String PRIVATE_CLASS_A_PREFIX
public static final String PRIVATE_CLASS_B_PREFIX
public static final String PRIVATE_CLASS_C_PREFIX
public static final String CARRIER_GRADE_NAT_PREFIX
public static final String BROADCAST_ADDRESS
public static final SshdSocketAddress LOCALHOST_ADDRESS
null
spublic static final Comparator<InetAddress> BY_HOST_ADDRESS
InetAddress
-es according to their InetAddress.getHostAddress()
value case insensitivepublic SshdSocketAddress(int port)
public SshdSocketAddress(String hostName, int port)
public String getHostName()
public int getPort()
public InetSocketAddress toInetSocketAddress()
protected boolean isEquivalent(SshdSocketAddress that)
public static InetAddress getFirstExternalNetwork4Address()
public static List<InetAddress> getExternalNetwork4Addresses()
List
of local network addresses which are not multicast
or localhost sorted according to BY_HOST_ADDRESS
public static boolean isValidHostAddress(InetAddress addr)
addr
- The InetAddress
to be verifiedtrue
if the address is:
null
Inet4Address
InetAddress.isLinkLocalAddress()
,
InetAddress.isMulticastAddress()
,
InetAddress.isMulticastAddress()
public static boolean isLoopback(InetAddress addr)
addr
- The InetAddress
to be consideredtrue
if the address is a loopback one.
Note: if InetAddress.isLoopbackAddress()
returns false
the address string is checkedtoAddressString(InetAddress)
,
isLoopback(String)
public static boolean isLoopback(String ip)
ip
- IP value to be testedtrue
if the IP is "localhost" or
"127.x.x.x".public static String toAddressString(InetAddress addr)
public static final boolean isIPv4Address(String addr)
public static final boolean isPrivateIPv4Address(String addr)
addr
- The address stringtrue
if this is one of the allocated private
blocks. Note: it assumes that the address string is
indeed an IPv4 addressisIPv4Address(String)
,
PRIVATE_CLASS_A_PREFIX
,
PRIVATE_CLASS_B_PREFIX
,
PRIVATE_CLASS_C_PREFIX
,
Wiki pagepublic static final boolean isCarrierGradeNatIPv4Address(String addr)
addr
- The address to be checkedtrue
if the address is in the 100.64.0.0/10 rangepublic static final boolean isValidIPv4AddressComponent(CharSequence c)
Checks if the provided argument is a valid IPv4 address component:
null
/emptyc
- The CharSequence
to be validatetrue
if valid IPv4 address componentCopyright © 2008–2016 The Apache Software Foundation. All rights reserved.