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
Constructor and Description |
---|
SshdSocketAddress(InetSocketAddress addr) |
SshdSocketAddress(int port) |
SshdSocketAddress(String hostName,
int port) |
public static final String LOCALHOST_NAME
public static final String LOCALHOST_IPV4
public static final String IPV4_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 int IPV6_MAX_HEX_GROUPS
public static final int IPV6_MAX_HEX_DIGITS_PER_GROUP
public static final String IPV6_LONG_ANY_ADDRESS
public static final String IPV6_SHORT_ANY_ADDRESS
public static final String IPV6_LONG_LOCALHOST
public static final String IPV6_SHORT_LOCALHOST
public static final SshdSocketAddress LOCALHOST_ADDRESS
null
spublic static final Comparator<InetAddress> BY_HOST_ADDRESS
InetAddress
-es according to their InetAddress.getHostAddress()
value case
insensitivetoAddressString(InetAddress)
public static final Comparator<SocketAddress> BY_HOST_AND_PORT
SocketAddress
-es according to their host case insensitive and if equals, then according
to their port value (if any)public SshdSocketAddress(int port)
public SshdSocketAddress(InetSocketAddress addr)
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 verified
true
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 boolean isIPv4LoopbackAddress(String ip)
public static boolean isIPv6LoopbackAddress(String ip)
public static boolean isEquivalentHostName(String h1, String h2, boolean allowWildcard)
public static boolean isWildcardAddress(String addr)
public static SshdSocketAddress toSshdSocketAddress(SocketAddress addr)
public static String toAddressString(SocketAddress addr)
public static int toAddressPort(SocketAddress addr)
addr
- The SocketAddress
to examinepublic static InetSocketAddress toInetSocketAddress(SocketAddress remoteAddress)
Converts a SocketAddress
into an InetSocketAddress
if possible:
InetSocketAddress
then cast it as suchSshdSocketAddress
then invoke toInetSocketAddress()
remoteAddress
- The SocketAddress
- ignored if null
InetSocketAddress
instanceClassCastException
- if argument is not already an InetSocketAddress
or a SshdSocketAddress
public static String toAddressString(InetAddress addr)
public static boolean isIPv4Address(String addr)
public static 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 boolean isCarrierGradeNatIPv4Address(String addr)
addr
- The address to be checkedtrue
if the address is in the 100.64.0.0/10 rangepublic static 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 componentpublic static boolean isIPv6Address(String address)
public static <V> V findByOptionalWildcardAddress(Map<SshdSocketAddress,? extends V> map, SshdSocketAddress address)
public static <V> V removeByOptionalWildcardAddress(Map<SshdSocketAddress,? extends V> map, SshdSocketAddress address)
public static <V> Map.Entry<SshdSocketAddress,? extends V> findMatchingOptionalWildcardEntry(Map<SshdSocketAddress,? extends V> map, SshdSocketAddress address)
Copyright © 2008–2024 The Apache Software Foundation. All rights reserved.