public final class DnsNameResolverBuilder extends Object
DnsNameResolver builder.| Constructor and Description |
|---|
DnsNameResolverBuilder()
Creates a new builder.
|
DnsNameResolverBuilder(EventLoop eventLoop)
Creates a new builder.
|
| Modifier and Type | Method and Description |
|---|---|
DnsNameResolverBuilder |
authoritativeDnsServerCache(AuthoritativeDnsServerCache authoritativeDnsServerCache)
Sets the cache for authoritative NS servers
|
DnsNameResolverBuilder |
authoritativeDnsServerCache(DnsCache authoritativeDnsServerCache)
Deprecated.
|
DnsNameResolver |
build()
Returns a new
DnsNameResolver instance. |
protected ChannelFactory<? extends DatagramChannel> |
channelFactory()
Deprecated.
|
DnsNameResolverBuilder |
channelFactory(ChannelFactory<? extends DatagramChannel> datagramChannelFactory)
Deprecated.
|
DnsNameResolverBuilder |
channelType(Class<? extends DatagramChannel> channelType)
Deprecated.
|
DnsNameResolverBuilder |
cnameCache(DnsCnameCache cnameCache)
Sets the cache for
CNAME mappings. |
DnsNameResolverBuilder |
completeOncePreferredResolved(boolean completeOncePreferredResolved)
If
true SimpleNameResolver.resolveAll(String) will notify the returned Future as
soon as all queries for the preferred address-type are complete. |
static ResolvedAddressTypes |
computeResolvedAddressTypes(InternetProtocolFamily... internetProtocolFamilies)
Compute a
ResolvedAddressTypes from some InternetProtocolFamilys. |
DnsNameResolverBuilder |
consolidateCacheSize(int maxNumConsolidation)
Set the maximum size of the cache that is used to consolidate lookups for different hostnames when in-flight.
|
DnsNameResolverBuilder |
copy()
Creates a copy of this
DnsNameResolverBuilder |
DnsNameResolverBuilder |
datagramChannelFactory(ChannelFactory<? extends DatagramChannel> datagramChannelFactory)
Sets the
ChannelFactory that will create a DatagramChannel. |
DnsNameResolverBuilder |
datagramChannelStrategy(DnsNameResolverChannelStrategy datagramChannelStrategy)
Set the strategy that is used to determine how a
DatagramChannel is used by the resolver for sending
queries over UDP protocol. |
DnsNameResolverBuilder |
datagramChannelType(Class<? extends DatagramChannel> channelType)
Sets the
ChannelFactory as a ReflectiveChannelFactory of this type. |
DnsNameResolverBuilder |
decodeIdn(boolean decodeIdn)
Set if domain / host names should be decoded to unicode when received.
|
DnsNameResolverBuilder |
dnsQueryLifecycleObserverFactory(DnsQueryLifecycleObserverFactory lifecycleObserverFactory)
Set the factory used to generate objects which can observe individual DNS queries.
|
DnsNameResolverBuilder |
eventLoop(EventLoop eventLoop)
Sets the
EventLoop which will perform the communication with the DNS servers. |
DnsNameResolverBuilder |
hostsFileEntriesResolver(HostsFileEntriesResolver hostsFileEntriesResolver) |
DnsNameResolverBuilder |
localAddress(SocketAddress localAddress)
Configure the address that will be used to bind too.
|
DnsNameResolverBuilder |
maxPayloadSize(int maxPayloadSize)
Sets the capacity of the datagram packet buffer (in bytes).
|
DnsNameResolverBuilder |
maxQueriesPerResolve(int maxQueriesPerResolve)
Sets the maximum allowed number of DNS queries to send when resolving a host name.
|
protected DnsServerAddressStreamProvider |
nameServerProvider() |
DnsNameResolverBuilder |
nameServerProvider(DnsServerAddressStreamProvider dnsServerAddressStreamProvider)
Set the
DnsServerAddressStreamProvider which is used to determine which DNS server is used to resolve
each hostname. |
DnsNameResolverBuilder |
ndots(int ndots)
Set the number of dots which must appear in a name before an initial absolute query is made.
|
DnsNameResolverBuilder |
negativeTtl(int negativeTtl)
Sets the TTL of the cache for the failed DNS queries (in seconds).
|
DnsNameResolverBuilder |
optResourceEnabled(boolean optResourceEnabled)
Enable the automatic inclusion of a optional records that tries to give the remote DNS server a hint about
how much data the resolver can read per response.
|
protected DnsServerAddressStream |
queryServerAddressStream() |
DnsNameResolverBuilder |
queryServerAddressStream(DnsServerAddressStream queryServerAddressStream)
Set the
DnsServerAddressStream which provides the server address for DNS queries. |
DnsNameResolverBuilder |
queryTimeoutMillis(long queryTimeoutMillis)
Sets the timeout of each DNS query performed by this resolver (in milliseconds).
|
DnsNameResolverBuilder |
recursionDesired(boolean recursionDesired)
Sets if this resolver has to send a DNS query with the RD (recursion desired) flag set.
|
DnsNameResolverBuilder |
resolveCache(DnsCache resolveCache)
Sets the cache for resolution results.
|
DnsNameResolverBuilder |
resolvedAddressTypes(ResolvedAddressTypes resolvedAddressTypes)
Sets the list of the protocol families of the address resolved.
|
DnsNameResolverBuilder |
searchDomains(Iterable<String> searchDomains)
Set the list of search domains of the resolver.
|
DnsNameResolverBuilder |
socketChannelFactory(ChannelFactory<? extends SocketChannel> channelFactory)
|
DnsNameResolverBuilder |
socketChannelFactory(ChannelFactory<? extends SocketChannel> channelFactory,
boolean retryOnTimeout)
|
DnsNameResolverBuilder |
socketChannelType(Class<? extends SocketChannel> channelType)
|
DnsNameResolverBuilder |
socketChannelType(Class<? extends SocketChannel> channelType,
boolean retryOnTimeout)
|
DnsNameResolverBuilder |
traceEnabled(boolean traceEnabled)
Deprecated.
Prefer to configure
a
LoggingDnsQueryLifeCycleObserverFactory instead. |
DnsNameResolverBuilder |
ttl(int minTtl,
int maxTtl)
Sets the minimum and maximum TTL of the cached DNS resource records (in seconds).
|
public DnsNameResolverBuilder eventLoop(EventLoop eventLoop)
EventLoop which will perform the communication with the DNS servers.eventLoop - the EventLoopthis@Deprecated protected ChannelFactory<? extends DatagramChannel> channelFactory()
@Deprecated public DnsNameResolverBuilder channelFactory(ChannelFactory<? extends DatagramChannel> datagramChannelFactory)
datagramChannelFactory(ChannelFactory)ChannelFactory that will create a DatagramChannel.
If TCP fallback should be supported as well it is required
to call the socketChannelFactory(ChannelFactory) or socketChannelType(Class) method.
datagramChannelFactory - the ChannelFactorythispublic DnsNameResolverBuilder datagramChannelFactory(ChannelFactory<? extends DatagramChannel> datagramChannelFactory)
ChannelFactory that will create a DatagramChannel.
If TCP fallback should be supported as well it is required
to call the socketChannelFactory(ChannelFactory) or socketChannelType(Class) method.
datagramChannelFactory - the ChannelFactorythis@Deprecated public DnsNameResolverBuilder channelType(Class<? extends DatagramChannel> channelType)
datagramChannelType(Class)ChannelFactory as a ReflectiveChannelFactory of this type.
Use as an alternative to channelFactory(ChannelFactory).
If TCP fallback should be supported as well it is required
to call the socketChannelFactory(ChannelFactory) or socketChannelType(Class) method.
channelType - the typethispublic DnsNameResolverBuilder datagramChannelType(Class<? extends DatagramChannel> channelType)
ChannelFactory as a ReflectiveChannelFactory of this type.
Use as an alternative to datagramChannelFactory(ChannelFactory).
If TCP fallback should be supported as well it is required
to call the socketChannelFactory(ChannelFactory) or socketChannelType(Class) method.
channelType - the typethispublic DnsNameResolverBuilder socketChannelFactory(ChannelFactory<? extends SocketChannel> channelFactory)
ChannelFactory that will create a SocketChannel for
TCP fallback if needed.
TCP fallback is not enabled by default and must be enabled by providing a non-null
ChannelFactory for this method.
channelFactory - the ChannelFactory or null
if TCP fallback should not be supported.
By default, TCP fallback is not enabled.thispublic DnsNameResolverBuilder socketChannelType(Class<? extends SocketChannel> channelType)
ChannelFactory as a ReflectiveChannelFactory of this type for
TCP fallback if needed.
Use as an alternative to socketChannelFactory(ChannelFactory).
TCP fallback is not enabled by default and must be enabled by providing a non-null
channelType for this method.
channelType - the type or null if TCP fallback
should not be supported. By default, TCP fallback is not enabled.thispublic DnsNameResolverBuilder socketChannelFactory(ChannelFactory<? extends SocketChannel> channelFactory, boolean retryOnTimeout)
ChannelFactory that will create a SocketChannel for
TCP fallback if needed.
TCP fallback is not enabled by default and must be enabled by providing a non-null
ChannelFactory for this method.
channelFactory - the ChannelFactory or null
if TCP fallback should not be supported.
By default, TCP fallback is not enabled.retryOnTimeout - if true the DnsNameResolver will also fallback to TCP if a timeout
was detected, if false it will only try to use TCP if the response was marked
as truncated.thispublic DnsNameResolverBuilder socketChannelType(Class<? extends SocketChannel> channelType, boolean retryOnTimeout)
ChannelFactory as a ReflectiveChannelFactory of this type for
TCP fallback if needed.
Use as an alternative to socketChannelFactory(ChannelFactory).
TCP fallback is not enabled by default and must be enabled by providing a non-null
channelType for this method.
channelType - the type or null if TCP fallback
should not be supported. By default, TCP fallback is not enabled.retryOnTimeout - if true the DnsNameResolver will also fallback to TCP if a timeout
was detected, if false it will only try to use TCP if the response was marked
as truncated.thispublic DnsNameResolverBuilder resolveCache(DnsCache resolveCache)
resolveCache - the DNS resolution results cachethispublic DnsNameResolverBuilder cnameCache(DnsCnameCache cnameCache)
CNAME mappings.cnameCache - the cache used to cache CNAME mappings for a domain.thispublic DnsNameResolverBuilder dnsQueryLifecycleObserverFactory(DnsQueryLifecycleObserverFactory lifecycleObserverFactory)
lifecycleObserverFactory - the factory used to generate objects which can observe individual DNS queries.this@Deprecated public DnsNameResolverBuilder authoritativeDnsServerCache(DnsCache authoritativeDnsServerCache)
authoritativeDnsServerCache(AuthoritativeDnsServerCache)authoritativeDnsServerCache - the authoritative NS servers cachethispublic DnsNameResolverBuilder authoritativeDnsServerCache(AuthoritativeDnsServerCache authoritativeDnsServerCache)
authoritativeDnsServerCache - the authoritative NS servers cachethispublic DnsNameResolverBuilder localAddress(SocketAddress localAddress)
null the default will be used.localAddress - the bind addressthispublic DnsNameResolverBuilder ttl(int minTtl, int maxTtl)
0 and Integer.MAX_VALUE, which practically tells this resolver to
respect the TTL from the DNS server.minTtl - the minimum TTLmaxTtl - the maximum TTLthispublic DnsNameResolverBuilder negativeTtl(int negativeTtl)
negativeTtl - the TTL for failed cached queriesthispublic DnsNameResolverBuilder queryTimeoutMillis(long queryTimeoutMillis)
0 disables the timeout. If not set or a negative number is set, the default timeout is used.queryTimeoutMillis - the query timeoutthispublic static ResolvedAddressTypes computeResolvedAddressTypes(InternetProtocolFamily... internetProtocolFamilies)
ResolvedAddressTypes from some InternetProtocolFamilys.
An empty input will return the default value, based on "java.net" System properties.
Valid inputs are (), (IPv4), (IPv6), (Ipv4, IPv6) and (IPv6, IPv4).internetProtocolFamilies - a valid sequence of InternetProtocolFamilysResolvedAddressTypespublic DnsNameResolverBuilder resolvedAddressTypes(ResolvedAddressTypes resolvedAddressTypes)
computeResolvedAddressTypes(InternetProtocolFamily...)
to get a ResolvedAddressTypes out of some InternetProtocolFamilys.resolvedAddressTypes - the address typesthispublic DnsNameResolverBuilder completeOncePreferredResolved(boolean completeOncePreferredResolved)
true SimpleNameResolver.resolveAll(String) will notify the returned Future as
soon as all queries for the preferred address-type are complete.completeOncePreferredResolved - true to enable, false to disable.thispublic DnsNameResolverBuilder recursionDesired(boolean recursionDesired)
recursionDesired - true if recursion is desiredthispublic DnsNameResolverBuilder maxQueriesPerResolve(int maxQueriesPerResolve)
maxQueriesPerResolve - the max number of queriesthis@Deprecated public DnsNameResolverBuilder traceEnabled(boolean traceEnabled)
LoggingDnsQueryLifeCycleObserverFactory instead.traceEnabled - true if trace is enabledthispublic DnsNameResolverBuilder maxPayloadSize(int maxPayloadSize)
4096 bytes.maxPayloadSize - the capacity of the datagram packet bufferthispublic DnsNameResolverBuilder optResourceEnabled(boolean optResourceEnabled)
optResourceEnabled - if optional records inclusion is enabledthispublic DnsNameResolverBuilder hostsFileEntriesResolver(HostsFileEntriesResolver hostsFileEntriesResolver)
hostsFileEntriesResolver - the HostsFileEntriesResolver used to first check
if the hostname is locally aliased.thisprotected DnsServerAddressStreamProvider nameServerProvider()
public DnsNameResolverBuilder nameServerProvider(DnsServerAddressStreamProvider dnsServerAddressStreamProvider)
DnsServerAddressStreamProvider which is used to determine which DNS server is used to resolve
each hostname.this.protected DnsServerAddressStream queryServerAddressStream()
public DnsNameResolverBuilder queryServerAddressStream(DnsServerAddressStream queryServerAddressStream)
DnsServerAddressStream which provides the server address for DNS queries.this.public DnsNameResolverBuilder searchDomains(Iterable<String> searchDomains)
searchDomains - the search domainsthispublic DnsNameResolverBuilder ndots(int ndots)
1.ndots - the ndots valuethispublic DnsNameResolverBuilder decodeIdn(boolean decodeIdn)
decodeIdn - if should get decodedthispublic DnsNameResolverBuilder consolidateCacheSize(int maxNumConsolidation)
maxNumConsolidation - the maximum lookups to consolidate (different hostnames), or 0 if
no consolidation should be performed.thispublic DnsNameResolverBuilder datagramChannelStrategy(DnsNameResolverChannelStrategy datagramChannelStrategy)
DatagramChannel is used by the resolver for sending
queries over UDP protocol.datagramChannelStrategy - the DnsNameResolverChannelStrategy to use when doing queries over
UDP protocol.thispublic DnsNameResolver build()
DnsNameResolver instance.DnsNameResolverpublic DnsNameResolverBuilder copy()
DnsNameResolverBuilderDnsNameResolverBuilderCopyright © 2008–2025 The Netty Project. All rights reserved.