java.lang.Object
io.lettuce.core.resource.DirContextDnsResolver
- All Implemented Interfaces:
DnsResolver,Closeable,AutoCloseable
public class DirContextDnsResolver extends Object implements DnsResolver, Closeable
DNS Resolver based on Java's
com.sun.jndi.dns.DnsContextFactory. This resolver resolves hostnames to IPv4 and IPv6
addresses using A, AAAA and CNAME records. Java IP stack preferences are read from system properties
and taken into account when resolving names.
The default configuration uses system-configured DNS server addresses to perform lookups but server adresses can be specified
using DirContextDnsResolver(Iterable). Custom DNS servers can be specified by using
DirContextDnsResolver(String) or DirContextDnsResolver(Iterable).
- Since:
- 4.2
- Author:
- Mark Paluch
-
Constructor Summary
Constructors Constructor Description DirContextDnsResolver()Creates a newDirContextDnsResolverusing system-configured DNS servers.DirContextDnsResolver(boolean preferIpv4, boolean preferIpv6, Properties properties)Creates a newDirContextDnsResolverfor the given stack preference andproperties.DirContextDnsResolver(Iterable<String> dnsServers)Creates a newDirContextDnsResolverusing a collection of DNS servers.DirContextDnsResolver(String dnsServer)Creates a newDirContextDnsResolverusing a collection of DNS servers. -
Method Summary
Modifier and Type Method Description voidclose()InetAddress[]resolve(String host)Perform hostname to address resolution.
-
Constructor Details
-
DirContextDnsResolver
public DirContextDnsResolver()Creates a newDirContextDnsResolverusing system-configured DNS servers. -
DirContextDnsResolver
Creates a newDirContextDnsResolverusing a collection of DNS servers.- Parameters:
dnsServer- must not benulland not empty.
-
DirContextDnsResolver
Creates a newDirContextDnsResolverusing a collection of DNS servers.- Parameters:
dnsServers- must not benulland not empty.
-
DirContextDnsResolver
Creates a newDirContextDnsResolverfor the given stack preference andproperties.- Parameters:
preferIpv4- flag to prefer IPv4 over IPv6 address resolution.preferIpv6- flag to prefer IPv6 over IPv4 address resolution.properties- custom properties for creating the context, must not benull.
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
resolve
Perform hostname to address resolution.- Specified by:
resolvein interfaceDnsResolver- Parameters:
host- the hostname, must not be empty ornull.- Returns:
- array of one or more
addresses - Throws:
UnknownHostException
-