Package io.netty.resolver.dns
Class DnsNameResolver
java.lang.Object
io.netty.resolver.SimpleNameResolver<InetAddress>
io.netty.resolver.InetNameResolver
io.netty.resolver.dns.DnsNameResolver
- All Implemented Interfaces:
NameResolver<InetAddress>
,Closeable
,AutoCloseable
A DNS-based
InetNameResolver
.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
private static final class
private static interface
private static final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AuthoritativeDnsServerCache
private final DnsCnameCache
private final boolean
private static final DatagramDnsResponseDecoder
private static final DatagramDnsQueryEncoder
private final boolean
private static final UnixResolverOptions
(package private) static final ResolvedAddressTypes
(package private) static final String[]
static final AttributeKey
<Boolean> An attribute used to mark all channels created by theDnsNameResolver
.private final DnsQueryLifecycleObserverFactory
private final DnsServerAddressStreamProvider
private static final DnsRecord[]
private final HostsFileEntriesResolver
private final Map
<String, Future<List<InetAddress>>> private static final InternetProtocolFamily[]
private static final DnsRecordType[]
private static final InternetProtocolFamily[]
private static final DnsRecordType[]
private static final InternetProtocolFamily[]
private static final DnsRecordType[]
private static final InternetProtocolFamily[]
private static final DnsRecordType[]
private static final String
private static final InetAddress
private static final InternalLogger
private final int
private final int
private final int
private final Comparator
<InetSocketAddress> private final int
private static final ChannelHandler
private final boolean
private final InternetProtocolFamily
private final DnsQueryContextManager
Manages theDnsQueryContext
s in progress and their query IDs.private final DnsServerAddressStream
private final long
private final boolean
private final DnsCache
Cache fordoResolve(String, Promise)
anddoResolveAll(String, Promise)
.private final DnsNameResolver.DnsResolveChannelProvider
private final ResolvedAddressTypes
private final InternetProtocolFamily[]
private final DnsRecordType[]
private final boolean
private final String[]
private final Bootstrap
private final boolean
private final boolean
private static final String
-
Constructor Summary
ConstructorsConstructorDescriptionDnsNameResolver
(EventLoop eventLoop, ChannelFactory<? extends DatagramChannel> channelFactory, ChannelFactory<? extends SocketChannel> socketChannelFactory, boolean retryWithTcpOnTimeout, DnsCache resolveCache, DnsCnameCache cnameCache, AuthoritativeDnsServerCache authoritativeDnsServerCache, SocketAddress localAddress, DnsQueryLifecycleObserverFactory dnsQueryLifecycleObserverFactory, long queryTimeoutMillis, ResolvedAddressTypes resolvedAddressTypes, boolean recursionDesired, int maxQueriesPerResolve, boolean traceEnabled, int maxPayloadSize, boolean optResourceEnabled, HostsFileEntriesResolver hostsFileEntriesResolver, DnsServerAddressStreamProvider dnsServerAddressStreamProvider, DnsServerAddressStream queryDnsServerAddressStream, String[] searchDomains, int ndots, boolean decodeIdn, boolean completeOncePreferredResolved, int maxNumConsolidation, DnsNameResolverChannelStrategy datagramChannelStrategy) DnsNameResolver
(EventLoop eventLoop, ChannelFactory<? extends DatagramChannel> channelFactory, DnsCache resolveCache, AuthoritativeDnsServerCache authoritativeDnsServerCache, DnsQueryLifecycleObserverFactory dnsQueryLifecycleObserverFactory, long queryTimeoutMillis, ResolvedAddressTypes resolvedAddressTypes, boolean recursionDesired, int maxQueriesPerResolve, boolean traceEnabled, int maxPayloadSize, boolean optResourceEnabled, HostsFileEntriesResolver hostsFileEntriesResolver, DnsServerAddressStreamProvider dnsServerAddressStreamProvider, String[] searchDomains, int ndots, boolean decodeIdn) Deprecated.DnsNameResolver
(EventLoop eventLoop, ChannelFactory<? extends DatagramChannel> channelFactory, DnsCache resolveCache, DnsCache authoritativeDnsServerCache, DnsQueryLifecycleObserverFactory dnsQueryLifecycleObserverFactory, long queryTimeoutMillis, ResolvedAddressTypes resolvedAddressTypes, boolean recursionDesired, int maxQueriesPerResolve, boolean traceEnabled, int maxPayloadSize, boolean optResourceEnabled, HostsFileEntriesResolver hostsFileEntriesResolver, DnsServerAddressStreamProvider dnsServerAddressStreamProvider, String[] searchDomains, int ndots, boolean decodeIdn) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionprivate static boolean
Returns the cache used for authoritative DNS servers for a domain.private static Promise
<AddressedEnvelope<DnsResponse, InetSocketAddress>> void
close()
Closes the internal datagram channel used for sending and receiving DNS messages, and clears all DNS resource records from the cache.Returns theDnsCnameCache
.(package private) final DnsQueryLifecycleObserverFactory
(package private) final Future
<AddressedEnvelope<DnsResponse, InetSocketAddress>> doQuery
(Channel channel, InetSocketAddress nameServerAddr, DnsQuestion question, DnsQueryLifecycleObserver queryLifecycleObserver, DnsRecord[] additionals, boolean flush, Promise<AddressedEnvelope<? extends DnsResponse, InetSocketAddress>> promise) protected void
doResolve
(String inetHost, DnsRecord[] additionals, Promise<InetAddress> promise, DnsCache resolveCache) Hook designed for extensibility so one can pass a different cache on each resolution attempt instead of using the global one.protected void
doResolve
(String inetHost, Promise<InetAddress> promise) Invoked bySimpleNameResolver.resolve(String)
to perform the actual name resolution.protected void
doResolveAll
(String inetHost, DnsRecord[] additionals, Promise<List<InetAddress>> promise, DnsCache resolveCache) Hook designed for extensibility so one can pass a different cache on each resolution attempt instead of using the global one.protected void
doResolveAll
(String inetHost, Promise<List<InetAddress>> promise) Invoked bySimpleNameResolver.resolveAll(String)
to perform the actual name resolution.(package private) static boolean
doResolveAllCached
(String hostname, DnsRecord[] additionals, Promise<List<InetAddress>> promise, DnsCache resolveCache, String[] searchDomains, int ndots, InternetProtocolFamily[] resolvedInternetProtocolFamilies) private void
doResolveAllNow
(ChannelFuture f, String hostname, DnsRecord[] additionals, Promise<List<InetAddress>> promise, DnsCache resolveCache) private void
doResolveAllUncached
(Channel channel, String hostname, DnsRecord[] additionals, Promise<?> originalPromise, Promise<List<InetAddress>> promise, DnsCache resolveCache, boolean completeEarlyIfPossible) private void
doResolveAllUncached0
(Channel channel, String hostname, DnsRecord[] additionals, Promise<?> originalPromise, Promise<List<InetAddress>> promise, DnsCache resolveCache, boolean completeEarlyIfPossible) private boolean
doResolveCached
(String hostname, DnsRecord[] additionals, Promise<InetAddress> promise, DnsCache resolveCache) private void
doResolveNow
(ChannelFuture f, String hostname, DnsRecord[] additionals, Promise<InetAddress> promise, DnsCache resolveCache) private void
doResolveUncached
(Channel channel, String hostname, DnsRecord[] additionals, Promise<InetAddress> promise, DnsCache resolveCache, boolean completeEarlyIfPossible) protected EventLoop
executor()
Returns theEventExecutor
which is used to notify the listeners of theFuture
returned bySimpleNameResolver.resolve(String)
.private static boolean
hasEntries
(List<? extends DnsCacheEntry> cachedEntries) private static String
Returns the component that tries to resolve hostnames against the hosts file prior to asking to remotes DNS servers.(package private) final boolean
private static boolean
isLocalWindowsHost
(String hostname) Checks whether the given hostname is the localhost/host (computer) name on Windows OS.boolean
Returns 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 is enabled.boolean
Returnstrue
if and only if this resolver sends a DNS query with the RD (recursion desired) flag set.static boolean
isTimeoutError
(Throwable cause) Returnstrue
if theThrowable
was caused by an timeout.static boolean
Returnstrue
if theThrowable
was caused by an timeout or transport error.private InetAddress
int
Returns the capacity of the datagram packet buffer (in bytes).int
Returns the maximum allowed number of DNS queries to send when resolving a host name.(package private) final int
ndots()
(package private) final DnsServerAddressStream
newNameServerAddressStream
(String hostname) private static DnsNameResolver.DnsResolveChannelProvider
newProvider
(DnsNameResolverChannelStrategy channelStrategy, Bootstrap bootstrap, SocketAddress localAddress) protected DnsServerAddressStream
newRedirectDnsServerStream
(String hostname, List<InetSocketAddress> nameservers) Creates a newDnsServerAddressStream
to following a redirected DNS query.(package private) InetSocketAddress
newRedirectServerAddress
(InetAddress server) private InetSocketAddress
(package private) final InternetProtocolFamily
(package private) static InternetProtocolFamily
preferredAddressType
(ResolvedAddressTypes resolvedAddressTypes) query
(DnsQuestion question) Sends a DNS query with the specified question.query
(DnsQuestion question, Promise<AddressedEnvelope<? extends DnsResponse, InetSocketAddress>> promise) Sends a DNS query with the specified question.query
(DnsQuestion question, Iterable<DnsRecord> additionals) Sends a DNS query with the specified question with additional records.query
(InetSocketAddress nameServerAddr, DnsQuestion question) Sends a DNS query with the specified question using the specified name server list.query
(InetSocketAddress nameServerAddr, DnsQuestion question, Promise<AddressedEnvelope<? extends DnsResponse, InetSocketAddress>> promise) Sends a DNS query with the specified question using the specified name server list.query
(InetSocketAddress nameServerAddr, DnsQuestion question, Iterable<DnsRecord> additionals) Sends a DNS query with the specified question with additional records using the specified name server list.query
(InetSocketAddress nameServerAddr, DnsQuestion question, Iterable<DnsRecord> additionals, Promise<AddressedEnvelope<? extends DnsResponse, InetSocketAddress>> promise) Sends a DNS query with the specified question with additional records using the specified name server list.Returns the dns server address stream used for DNS queries (not resolve).long
Returns the timeout of each DNS query performed by this resolver (in milliseconds).private static ChannelFuture
registerOrBind
(Bootstrap bootstrap, SocketAddress localAddress) final Future
<InetAddress> Resolves the specified name into an address.final Future
<InetAddress> Resolves the specified name into an address.resolveAll
(DnsQuestion question) Resolves theDnsRecord
s that are matched by the specifiedDnsQuestion
.resolveAll
(DnsQuestion question, DnsRecord[] additionals, Promise<List<DnsRecord>> promise) resolveAll
(DnsQuestion question, Iterable<DnsRecord> additionals) Resolves theDnsRecord
s that are matched by the specifiedDnsQuestion
.resolveAll
(DnsQuestion question, Iterable<DnsRecord> additionals, Promise<List<DnsRecord>> promise) Resolves theDnsRecord
s that are matched by the specifiedDnsQuestion
.final Future
<List<InetAddress>> resolveAll
(String inetHost, Iterable<DnsRecord> additionals) Resolves the specified host name and port into a list of address.final Future
<List<InetAddress>> resolveAll
(String inetHost, Iterable<DnsRecord> additionals, Promise<List<InetAddress>> promise) Resolves the specified host name and port into a list of address.private void
resolveAllNow
(ChannelFuture f, String hostname, DnsQuestion question, DnsRecord[] additionals, Promise<List<DnsRecord>> promise) Returns the resolution cache.Returns theResolvedAddressTypes
resolved bySimpleNameResolver.resolve(String)
.(package private) InternetProtocolFamily[]
private List
<InetAddress> resolveHostsFileEntries
(String hostname) private InetAddress
resolveHostsFileEntry
(String hostname) private void
resolveNow
(Channel channel, String hostname, DnsRecord[] additionals, Promise<?> originalPromise, Promise<List<InetAddress>> promise, DnsCache resolveCache, boolean completeEarlyIfPossible) (package private) final DnsRecordType[]
(package private) final String[]
(package private) final boolean
(package private) final boolean
private static DnsRecord[]
private static UnknownHostException
toException
(ChannelFuture f, String hostname, DnsQuestion question, DnsRecord[] additionals) private static void
tryFailure
(Promise<?> promise, Throwable cause) (package private) static <T> boolean
trySuccess
(Promise<T> promise, T result) private static void
validateAdditional
(DnsRecord record, boolean validateType) Methods inherited from class io.netty.resolver.InetNameResolver
asAddressResolver
Methods inherited from class io.netty.resolver.SimpleNameResolver
resolve, resolve, resolveAll, resolveAll
-
Field Details
-
DNS_PIPELINE_ATTRIBUTE
An attribute used to mark all channels created by theDnsNameResolver
. -
logger
-
LOCALHOST
- See Also:
-
WINDOWS_HOST_NAME
-
LOCALHOST_ADDRESS
-
EMPTY_ADDITIONALS
-
IPV4_ONLY_RESOLVED_RECORD_TYPES
-
IPV4_ONLY_RESOLVED_PROTOCOL_FAMILIES
-
IPV4_PREFERRED_RESOLVED_RECORD_TYPES
-
IPV4_PREFERRED_RESOLVED_PROTOCOL_FAMILIES
-
IPV6_ONLY_RESOLVED_RECORD_TYPES
-
IPV6_ONLY_RESOLVED_PROTOCOL_FAMILIES
-
IPV6_PREFERRED_RESOLVED_RECORD_TYPES
-
IPV6_PREFERRED_RESOLVED_PROTOCOL_FAMILIES
-
NOOP_HANDLER
-
DEFAULT_RESOLVE_ADDRESS_TYPES
-
DEFAULT_SEARCH_DOMAINS
-
DEFAULT_OPTIONS
-
DATAGRAM_DECODER
-
DATAGRAM_ENCODER
-
nameServerComparator
-
queryContextManager
Manages theDnsQueryContext
s in progress and their query IDs. -
resolveCache
Cache fordoResolve(String, Promise)
anddoResolveAll(String, Promise)
. -
authoritativeDnsServerCache
-
cnameCache
-
queryDnsServerAddressStream
-
queryTimeoutMillis
private final long queryTimeoutMillis -
maxQueriesPerResolve
private final int maxQueriesPerResolve -
resolvedAddressTypes
-
resolvedInternetProtocolFamilies
-
recursionDesired
private final boolean recursionDesired -
maxPayloadSize
private final int maxPayloadSize -
optResourceEnabled
private final boolean optResourceEnabled -
hostsFileEntriesResolver
-
dnsServerAddressStreamProvider
-
searchDomains
-
ndots
private final int ndots -
supportsAAAARecords
private final boolean supportsAAAARecords -
supportsARecords
private final boolean supportsARecords -
preferredAddressType
-
resolveRecordTypes
-
decodeIdn
private final boolean decodeIdn -
dnsQueryLifecycleObserverFactory
-
completeOncePreferredResolved
private final boolean completeOncePreferredResolved -
resolveChannelProvider
-
socketBootstrap
-
retryWithTcpOnTimeout
private final boolean retryWithTcpOnTimeout -
maxNumConsolidation
private final int maxNumConsolidation -
inflightLookups
-
-
Constructor Details
-
DnsNameResolver
@Deprecated public DnsNameResolver(EventLoop eventLoop, ChannelFactory<? extends DatagramChannel> channelFactory, DnsCache resolveCache, DnsCache authoritativeDnsServerCache, DnsQueryLifecycleObserverFactory dnsQueryLifecycleObserverFactory, long queryTimeoutMillis, ResolvedAddressTypes resolvedAddressTypes, boolean recursionDesired, int maxQueriesPerResolve, boolean traceEnabled, int maxPayloadSize, boolean optResourceEnabled, HostsFileEntriesResolver hostsFileEntriesResolver, DnsServerAddressStreamProvider dnsServerAddressStreamProvider, String[] searchDomains, int ndots, boolean decodeIdn) Deprecated.Creates a new DNS-based name resolver that communicates with the specified list of DNS servers.- Parameters:
eventLoop
- theEventLoop
which will perform the communication with the DNS serverschannelFactory
- theChannelFactory
that will create aDatagramChannel
resolveCache
- the DNS resolved entries cacheauthoritativeDnsServerCache
- the cache used to find the authoritative DNS server for a domaindnsQueryLifecycleObserverFactory
- used to generate new instances ofDnsQueryLifecycleObserver
which can be used to track metrics for DNS servers.queryTimeoutMillis
- timeout of each DNS query in millis.0
disables the timeout. If not set or a negative number is set, the default timeout is used.resolvedAddressTypes
- the preferred address typesrecursionDesired
- if recursion desired flag must be setmaxQueriesPerResolve
- the maximum allowed number of DNS queries for a given name resolutiontraceEnabled
- if trace is enabledmaxPayloadSize
- the capacity of the datagram packet bufferoptResourceEnabled
- if automatic inclusion of a optional records is enabledhostsFileEntriesResolver
- theHostsFileEntriesResolver
used to check for local aliasesdnsServerAddressStreamProvider
- TheDnsServerAddressStreamProvider
used to determine the name servers for each hostname lookup.searchDomains
- the list of search domain (can be null, if so, will try to default to the underlying platform ones)ndots
- the ndots valuedecodeIdn
-true
if domain / host names should be decoded to unicode when received. See rfc3492.
-
DnsNameResolver
@Deprecated public DnsNameResolver(EventLoop eventLoop, ChannelFactory<? extends DatagramChannel> channelFactory, DnsCache resolveCache, AuthoritativeDnsServerCache authoritativeDnsServerCache, DnsQueryLifecycleObserverFactory dnsQueryLifecycleObserverFactory, long queryTimeoutMillis, ResolvedAddressTypes resolvedAddressTypes, boolean recursionDesired, int maxQueriesPerResolve, boolean traceEnabled, int maxPayloadSize, boolean optResourceEnabled, HostsFileEntriesResolver hostsFileEntriesResolver, DnsServerAddressStreamProvider dnsServerAddressStreamProvider, String[] searchDomains, int ndots, boolean decodeIdn) Deprecated.Creates a new DNS-based name resolver that communicates with the specified list of DNS servers.- Parameters:
eventLoop
- theEventLoop
which will perform the communication with the DNS serverschannelFactory
- theChannelFactory
that will create aDatagramChannel
resolveCache
- the DNS resolved entries cacheauthoritativeDnsServerCache
- the cache used to find the authoritative DNS server for a domaindnsQueryLifecycleObserverFactory
- used to generate new instances ofDnsQueryLifecycleObserver
which can be used to track metrics for DNS servers.queryTimeoutMillis
- timeout of each DNS query in millis.0
disables the timeout. If not set or a negative number is set, the default timeout is used.resolvedAddressTypes
- the preferred address typesrecursionDesired
- if recursion desired flag must be setmaxQueriesPerResolve
- the maximum allowed number of DNS queries for a given name resolutiontraceEnabled
- if trace is enabledmaxPayloadSize
- the capacity of the datagram packet bufferoptResourceEnabled
- if automatic inclusion of a optional records is enabledhostsFileEntriesResolver
- theHostsFileEntriesResolver
used to check for local aliasesdnsServerAddressStreamProvider
- TheDnsServerAddressStreamProvider
used to determine the name servers for each hostname lookup.searchDomains
- the list of search domain (can be null, if so, will try to default to the underlying platform ones)ndots
- the ndots valuedecodeIdn
-true
if domain / host names should be decoded to unicode when received. See rfc3492.
-
DnsNameResolver
DnsNameResolver(EventLoop eventLoop, ChannelFactory<? extends DatagramChannel> channelFactory, ChannelFactory<? extends SocketChannel> socketChannelFactory, boolean retryWithTcpOnTimeout, DnsCache resolveCache, DnsCnameCache cnameCache, AuthoritativeDnsServerCache authoritativeDnsServerCache, SocketAddress localAddress, DnsQueryLifecycleObserverFactory dnsQueryLifecycleObserverFactory, long queryTimeoutMillis, ResolvedAddressTypes resolvedAddressTypes, boolean recursionDesired, int maxQueriesPerResolve, boolean traceEnabled, int maxPayloadSize, boolean optResourceEnabled, HostsFileEntriesResolver hostsFileEntriesResolver, DnsServerAddressStreamProvider dnsServerAddressStreamProvider, DnsServerAddressStream queryDnsServerAddressStream, String[] searchDomains, int ndots, boolean decodeIdn, boolean completeOncePreferredResolved, int maxNumConsolidation, DnsNameResolverChannelStrategy datagramChannelStrategy)
-
-
Method Details
-
anyInterfaceSupportsIpV6
private static boolean anyInterfaceSupportsIpV6() -
getSearchDomainsHack
- Throws:
Exception
-
newProvider
private static DnsNameResolver.DnsResolveChannelProvider newProvider(DnsNameResolverChannelStrategy channelStrategy, Bootstrap bootstrap, SocketAddress localAddress) -
preferredAddressType
-
newRedirectServerAddress
-
dnsQueryLifecycleObserverFactory
-
newRedirectDnsServerStream
protected DnsServerAddressStream newRedirectDnsServerStream(String hostname, List<InetSocketAddress> nameservers) Creates a newDnsServerAddressStream
to following a redirected DNS query. By overriding this it provides the opportunity to sort the name servers before following a redirected DNS query.- Parameters:
hostname
- the hostname.nameservers
- The addresses of the DNS servers which are used in the event of a redirect. This may contain resolved and unresolved addresses so the usedDnsServerAddressStream
must allow unresolved addresses if you want to include these as well.- Returns:
- A
DnsServerAddressStream
which will be used to follow the DNS redirect ornull
if none should be followed.
-
resolveCache
Returns the resolution cache. -
cnameCache
Returns theDnsCnameCache
. -
authoritativeDnsServerCache
Returns the cache used for authoritative DNS servers for a domain. -
queryTimeoutMillis
public long queryTimeoutMillis()Returns the timeout of each DNS query performed by this resolver (in milliseconds). The default value is 5 seconds. -
queryDnsServerAddressStream
Returns the dns server address stream used for DNS queries (not resolve). -
resolvedAddressTypes
Returns theResolvedAddressTypes
resolved bySimpleNameResolver.resolve(String)
. The default value depends on the value of the system property"java.net.preferIPv6Addresses"
. -
resolvedInternetProtocolFamiliesUnsafe
InternetProtocolFamily[] resolvedInternetProtocolFamiliesUnsafe() -
searchDomains
-
ndots
final int ndots() -
supportsAAAARecords
final boolean supportsAAAARecords() -
supportsARecords
final boolean supportsARecords() -
preferredAddressType
-
resolveRecordTypes
-
isDecodeIdn
final boolean isDecodeIdn() -
isRecursionDesired
public boolean isRecursionDesired()Returnstrue
if and only if this resolver sends a DNS query with the RD (recursion desired) flag set. The default value istrue
. -
maxQueriesPerResolve
public int maxQueriesPerResolve()Returns the maximum allowed number of DNS queries to send when resolving a host name. The default value is8
. -
maxPayloadSize
public int maxPayloadSize()Returns the capacity of the datagram packet buffer (in bytes). The default value is4096
bytes. -
isOptResourceEnabled
public boolean isOptResourceEnabled()Returns 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 is enabled. -
hostsFileEntriesResolver
Returns the component that tries to resolve hostnames against the hosts file prior to asking to remotes DNS servers. -
close
public void close()Closes the internal datagram channel used for sending and receiving DNS messages, and clears all DNS resource records from the cache. Attempting to send a DNS query or to resolve a domain name will fail once this method has been called.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceNameResolver<InetAddress>
- Overrides:
close
in classSimpleNameResolver<InetAddress>
-
executor
Description copied from class:SimpleNameResolver
Returns theEventExecutor
which is used to notify the listeners of theFuture
returned bySimpleNameResolver.resolve(String)
.- Overrides:
executor
in classSimpleNameResolver<InetAddress>
-
resolveHostsFileEntry
-
resolveHostsFileEntries
-
isLocalWindowsHost
Checks whether the given hostname is the localhost/host (computer) name on Windows OS. Windows OS removed the localhost/host (computer) name information from the hosts file in the later versions and such hostname cannot be resolved from hosts file. See https://github.com/netty/netty/issues/5386 See https://github.com/netty/netty/issues/11142 -
resolve
Resolves the specified name into an address.- Parameters:
inetHost
- the name to resolveadditionals
- additional records (OPT
)- Returns:
- the address as the result of the resolution
-
resolve
public final Future<InetAddress> resolve(String inetHost, Iterable<DnsRecord> additionals, Promise<InetAddress> promise) Resolves the specified name into an address.- Parameters:
inetHost
- the name to resolveadditionals
- additional records (OPT
)promise
- thePromise
which will be fulfilled when the name resolution is finished- Returns:
- the address as the result of the resolution
-
resolveAll
Resolves the specified host name and port into a list of address.- Parameters:
inetHost
- the name to resolveadditionals
- additional records (OPT
)- Returns:
- the list of the address as the result of the resolution
-
resolveAll
public final Future<List<InetAddress>> resolveAll(String inetHost, Iterable<DnsRecord> additionals, Promise<List<InetAddress>> promise) Resolves the specified host name and port into a list of address.- Parameters:
inetHost
- the name to resolveadditionals
- additional records (OPT
)promise
- thePromise
which will be fulfilled when the name resolution is finished- Returns:
- the list of the address as the result of the resolution
-
doResolve
Description copied from class:SimpleNameResolver
Invoked bySimpleNameResolver.resolve(String)
to perform the actual name resolution.- Specified by:
doResolve
in classSimpleNameResolver<InetAddress>
- Throws:
Exception
-
resolveAll
Resolves theDnsRecord
s that are matched by the specifiedDnsQuestion
. Unlikequery(DnsQuestion)
, this method handles redirection, CNAMEs and multiple name servers. If the specifiedDnsQuestion
isA
orAAAA
, this method looks up the configuredHostsFileEntries
before sending a query to the name servers. If a match is found in theHostsFileEntries
, a syntheticA
orAAAA
record will be returned.- Parameters:
question
- the question- Returns:
- the list of the
DnsRecord
s as the result of the resolution
-
resolveAll
public final Future<List<DnsRecord>> resolveAll(DnsQuestion question, Iterable<DnsRecord> additionals) Resolves theDnsRecord
s that are matched by the specifiedDnsQuestion
. Unlikequery(DnsQuestion)
, this method handles redirection, CNAMEs and multiple name servers. If the specifiedDnsQuestion
isA
orAAAA
, this method looks up the configuredHostsFileEntries
before sending a query to the name servers. If a match is found in theHostsFileEntries
, a syntheticA
orAAAA
record will be returned.- Parameters:
question
- the questionadditionals
- additional records (OPT
)- Returns:
- the list of the
DnsRecord
s as the result of the resolution
-
resolveAll
public final Future<List<DnsRecord>> resolveAll(DnsQuestion question, Iterable<DnsRecord> additionals, Promise<List<DnsRecord>> promise) Resolves theDnsRecord
s that are matched by the specifiedDnsQuestion
. Unlikequery(DnsQuestion)
, this method handles redirection, CNAMEs and multiple name servers. If the specifiedDnsQuestion
isA
orAAAA
, this method looks up the configuredHostsFileEntries
before sending a query to the name servers. If a match is found in theHostsFileEntries
, a syntheticA
orAAAA
record will be returned. -
resolveAll
-
resolveAllNow
private void resolveAllNow(ChannelFuture f, String hostname, DnsQuestion question, DnsRecord[] additionals, Promise<List<DnsRecord>> promise) -
toException
private static UnknownHostException toException(ChannelFuture f, String hostname, DnsQuestion question, DnsRecord[] additionals) -
toArray
-
validateAdditional
-
loopbackAddress
-
doResolve
protected void doResolve(String inetHost, DnsRecord[] additionals, Promise<InetAddress> promise, DnsCache resolveCache) throws Exception Hook designed for extensibility so one can pass a different cache on each resolution attempt instead of using the global one.- Throws:
Exception
-
doResolveNow
private void doResolveNow(ChannelFuture f, String hostname, DnsRecord[] additionals, Promise<InetAddress> promise, DnsCache resolveCache) -
doResolveCached
private boolean doResolveCached(String hostname, DnsRecord[] additionals, Promise<InetAddress> promise, DnsCache resolveCache) -
trySuccess
-
tryFailure
-
doResolveUncached
-
doResolveAll
Description copied from class:SimpleNameResolver
Invoked bySimpleNameResolver.resolveAll(String)
to perform the actual name resolution.- Specified by:
doResolveAll
in classSimpleNameResolver<InetAddress>
- Throws:
Exception
-
doResolveAll
protected void doResolveAll(String inetHost, DnsRecord[] additionals, Promise<List<InetAddress>> promise, DnsCache resolveCache) throws Exception Hook designed for extensibility so one can pass a different cache on each resolution attempt instead of using the global one.- Throws:
Exception
-
doResolveAllNow
private void doResolveAllNow(ChannelFuture f, String hostname, DnsRecord[] additionals, Promise<List<InetAddress>> promise, DnsCache resolveCache) -
hasEntries
-
doResolveAllCached
static boolean doResolveAllCached(String hostname, DnsRecord[] additionals, Promise<List<InetAddress>> promise, DnsCache resolveCache, String[] searchDomains, int ndots, InternetProtocolFamily[] resolvedInternetProtocolFamilies) -
doResolveAllUncached
-
doResolveAllUncached0
-
resolveNow
-
hostname
-
query
Sends a DNS query with the specified question. -
query
public Future<AddressedEnvelope<DnsResponse,InetSocketAddress>> query(DnsQuestion question, Iterable<DnsRecord> additionals) Sends a DNS query with the specified question with additional records. -
query
public Future<AddressedEnvelope<DnsResponse,InetSocketAddress>> query(DnsQuestion question, Promise<AddressedEnvelope<? extends DnsResponse, InetSocketAddress>> promise) Sends a DNS query with the specified question. -
nextNameServerAddress
-
query
public Future<AddressedEnvelope<DnsResponse,InetSocketAddress>> query(InetSocketAddress nameServerAddr, DnsQuestion question) Sends a DNS query with the specified question using the specified name server list. -
query
public Future<AddressedEnvelope<DnsResponse,InetSocketAddress>> query(InetSocketAddress nameServerAddr, DnsQuestion question, Iterable<DnsRecord> additionals) Sends a DNS query with the specified question with additional records using the specified name server list. -
query
public Future<AddressedEnvelope<DnsResponse,InetSocketAddress>> query(InetSocketAddress nameServerAddr, DnsQuestion question, Promise<AddressedEnvelope<? extends DnsResponse, InetSocketAddress>> promise) Sends a DNS query with the specified question using the specified name server list. -
query
public Future<AddressedEnvelope<DnsResponse,InetSocketAddress>> query(InetSocketAddress nameServerAddr, DnsQuestion question, Iterable<DnsRecord> additionals, Promise<AddressedEnvelope<? extends DnsResponse, InetSocketAddress>> promise) Sends a DNS query with the specified question with additional records using the specified name server list. -
isTransportOrTimeoutError
Returnstrue
if theThrowable
was caused by an timeout or transport error. These methods can be used on theFuture.cause()
that is returned by the various methods exposed by thisDnsNameResolver
. -
isTimeoutError
Returnstrue
if theThrowable
was caused by an timeout. These methods can be used on theFuture.cause()
that is returned by the various methods exposed by thisDnsNameResolver
. -
doQuery
final Future<AddressedEnvelope<DnsResponse,InetSocketAddress>> doQuery(Channel channel, InetSocketAddress nameServerAddr, DnsQuestion question, DnsQueryLifecycleObserver queryLifecycleObserver, DnsRecord[] additionals, boolean flush, Promise<AddressedEnvelope<? extends DnsResponse, InetSocketAddress>> promise) -
cast
-
newNameServerAddressStream
-
registerOrBind
-
DnsNameResolverBuilder
.