Package reactor.netty.transport
Class AddressUtils
java.lang.Object
reactor.netty.transport.AddressUtils
Internal class that creates unresolved or resolved InetSocketAddress instances
Numeric IPv4 and IPv6 addresses will be detected and parsed by using Netty's
NetUtil.createByteArrayFromIpAddressString(java.lang.String)
utility method and the
InetSocketAddress instances will be created in a way that these instances are resolved
initially. This removes the need to do unnecessary reverse DNS lookups.-
Method Summary
Modifier and TypeMethodDescriptionstatic InetSocketAddress
createInetSocketAddress
(String hostname, int port, boolean resolve) Creates InetSocketAddress instance.static InetSocketAddress
createResolved
(String hostname, int port) Creates InetSocketAddress that is always resolved.static InetSocketAddress
createUnresolved
(String hostname, int port) Creates unresolved InetSocketAddress.static InetSocketAddress
parseAddress
(String address, int defaultPort) Parse unresolved InetSocketAddress.static InetSocketAddress
parseAddress
(String address, int defaultPort, boolean strict) Parse unresolved InetSocketAddress.static InetSocketAddress
replaceUnresolvedNumericIp
(InetSocketAddress inetSocketAddress) Replaces an unresolved InetSocketAddress with a resolved instance in the case that the passed address is a numeric IP address (both IPv4 and IPv6 are supported).static InetSocketAddress
replaceWithResolved
(InetSocketAddress inetSocketAddress) Replaces an unresolved InetSocketAddress with a resolved instance in the case that the passed address is unresolved.static SocketAddress
updateHost
(@Nullable Supplier<? extends SocketAddress> address, String host) Update the provided address with the new host string.static SocketAddress
updatePort
(@Nullable Supplier<? extends SocketAddress> address, int port) Update the provided address with the new port.
-
Method Details
-
createInetSocketAddress
Creates InetSocketAddress instance. Numeric IP addresses will be detected and resolved without doing reverse DNS lookups.- Parameters:
hostname
- ip-address or hostnameport
- port numberresolve
- when true, resolve given hostname at instance creation time- Returns:
- InetSocketAddress for given parameters
-
createResolved
Creates InetSocketAddress that is always resolved. Numeric IP addresses will be detected and resolved without doing reverse DNS lookups.- Parameters:
hostname
- ip-address or hostnameport
- port number- Returns:
- InetSocketAddress for given parameters
-
createUnresolved
Creates unresolved InetSocketAddress. Numeric IP addresses will be detected and resolved.- Parameters:
hostname
- ip-address or hostnameport
- port number- Returns:
- InetSocketAddress for given parameters
-
parseAddress
Parse unresolved InetSocketAddress. Numeric IP addresses will be detected and resolved.- Parameters:
address
- ip-address or hostnamedefaultPort
- the default port- Returns:
InetSocketAddress
for given parameters, only numeric IP addresses will be resolved
-
parseAddress
Parse unresolved InetSocketAddress. Numeric IP addresses will be detected and resolved.- Parameters:
address
- ip-address or hostnamedefaultPort
- is used if the address does not contain a port, or if the port cannot be parsed in non-strict modestrict
- if true throws an exception when the address cannot be parsed, otherwise an unresolvedInetSocketAddress
is returned. It can include the case of the host having been parsed but not the port (replaced bydefaultPort
)- Returns:
InetSocketAddress
for given parameters, only numeric IP addresses will be resolved
-
replaceUnresolvedNumericIp
Replaces an unresolved InetSocketAddress with a resolved instance in the case that the passed address is a numeric IP address (both IPv4 and IPv6 are supported).- Parameters:
inetSocketAddress
- socket address instance to process- Returns:
- processed socket address instance
-
replaceWithResolved
Replaces an unresolved InetSocketAddress with a resolved instance in the case that the passed address is unresolved.- Parameters:
inetSocketAddress
- socket address instance to process- Returns:
- resolved instance with same host string and port
-
updateHost
public static SocketAddress updateHost(@Nullable Supplier<? extends SocketAddress> address, String host) Update the provided address with the new host string.- Parameters:
address
- the address supplierhost
- the new host string- Returns:
- the updated address
-
updatePort
public static SocketAddress updatePort(@Nullable Supplier<? extends SocketAddress> address, int port) Update the provided address with the new port.- Parameters:
address
- the address supplierport
- the new port- Returns:
- the updated address
-