public class DnsNameResolver extends io.netty.resolver.SimpleNameResolver<InetSocketAddress>
NameResolver.| Constructor and Description |
|---|
DnsNameResolver(io.netty.channel.EventLoop eventLoop,
io.netty.channel.ChannelFactory<? extends io.netty.channel.socket.DatagramChannel> channelFactory,
DnsServerAddresses nameServerAddresses)
Creates a new DNS-based name resolver that communicates with the specified list of DNS servers.
|
DnsNameResolver(io.netty.channel.EventLoop eventLoop,
io.netty.channel.ChannelFactory<? extends io.netty.channel.socket.DatagramChannel> channelFactory,
InetSocketAddress localAddress,
DnsServerAddresses nameServerAddresses)
Creates a new DNS-based name resolver that communicates with the specified list of DNS servers.
|
DnsNameResolver(io.netty.channel.EventLoop eventLoop,
Class<? extends io.netty.channel.socket.DatagramChannel> channelType,
DnsServerAddresses nameServerAddresses)
Creates a new DNS-based name resolver that communicates with the specified list of DNS servers.
|
DnsNameResolver(io.netty.channel.EventLoop eventLoop,
Class<? extends io.netty.channel.socket.DatagramChannel> channelType,
InetSocketAddress localAddress,
DnsServerAddresses nameServerAddresses)
Creates a new DNS-based name resolver that communicates with the specified list of DNS servers.
|
| Modifier and Type | Method and Description |
|---|---|
DnsNameResolver |
clearCache()
Clears all the resolved addresses cached by this resolver.
|
boolean |
clearCache(String hostname)
Clears the resolved addresses of the specified host name from the cache of this resolver.
|
void |
close()
Closes the internal datagram channel used for sending and receiving DNS messages, and clears all DNS resource
records from the cache.
|
protected boolean |
doIsResolved(InetSocketAddress address) |
protected void |
doResolve(InetSocketAddress unresolvedAddress,
io.netty.util.concurrent.Promise<InetSocketAddress> promise) |
protected void |
doResolveAll(InetSocketAddress unresolvedAddress,
io.netty.util.concurrent.Promise<List<InetSocketAddress>> promise) |
protected io.netty.channel.EventLoop |
executor() |
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.
|
boolean |
isRecursionDesired()
Returns
true if and only if this resolver sends a DNS query with the RD (recursion desired) flag set. |
boolean |
isTraceEnabled()
Returns if this resolver should generate the detailed trace information in an exception message so that
it is easier to understand the cause of resolution failure.
|
int |
maxPayloadSize()
Returns the capacity of the datagram packet buffer (in bytes).
|
int |
maxQueriesPerResolve()
Returns the maximum allowed number of DNS queries to send when resolving a host name.
|
int |
maxTtl()
Returns the maximum TTL of the cached DNS resource records (in seconds).
|
int |
minTtl()
Returns the minimum TTL of the cached DNS resource records (in seconds).
|
int |
negativeTtl()
Returns the TTL of the cache for the failed DNS queries (in seconds).
|
io.netty.util.concurrent.Future<io.netty.channel.AddressedEnvelope<io.netty.handler.codec.dns.DnsResponse,InetSocketAddress>> |
query(io.netty.handler.codec.dns.DnsQuestion question)
Sends a DNS query with the specified question.
|
io.netty.util.concurrent.Future<io.netty.channel.AddressedEnvelope<io.netty.handler.codec.dns.DnsResponse,InetSocketAddress>> |
query(io.netty.handler.codec.dns.DnsQuestion question,
io.netty.util.concurrent.Promise<io.netty.channel.AddressedEnvelope<? extends io.netty.handler.codec.dns.DnsResponse,InetSocketAddress>> promise)
Sends a DNS query with the specified question.
|
io.netty.util.concurrent.Future<io.netty.channel.AddressedEnvelope<io.netty.handler.codec.dns.DnsResponse,InetSocketAddress>> |
query(InetSocketAddress nameServerAddr,
io.netty.handler.codec.dns.DnsQuestion question)
Sends a DNS query with the specified question using the specified name server list.
|
io.netty.util.concurrent.Future<io.netty.channel.AddressedEnvelope<io.netty.handler.codec.dns.DnsResponse,InetSocketAddress>> |
query(InetSocketAddress nameServerAddr,
io.netty.handler.codec.dns.DnsQuestion question,
io.netty.util.concurrent.Promise<io.netty.channel.AddressedEnvelope<? extends io.netty.handler.codec.dns.DnsResponse,InetSocketAddress>> promise)
Sends a DNS query with the specified question using the specified name server list.
|
long |
queryTimeoutMillis()
Returns the timeout of each DNS query performed by this resolver (in milliseconds).
|
List<io.netty.channel.socket.InternetProtocolFamily> |
resolveAddressTypes()
Returns the list of the protocol families of the address resolved by
SimpleNameResolver.resolve(SocketAddress)
in the order of preference. |
DnsNameResolver |
setMaxPayloadSize(int maxPayloadSize)
Sets the capacity of the datagram packet buffer (in bytes).
|
DnsNameResolver |
setMaxQueriesPerResolve(int maxQueriesPerResolve)
Sets the maximum allowed number of DNS queries to send when resolving a host name.
|
DnsNameResolver |
setNegativeTtl(int negativeTtl)
Sets the TTL of the cache for the failed DNS queries (in seconds).
|
DnsNameResolver |
setOptResourceEnabled(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.
|
DnsNameResolver |
setQueryTimeoutMillis(long queryTimeoutMillis)
Sets the timeout of each DNS query performed by this resolver (in milliseconds).
|
DnsNameResolver |
setRecursionDesired(boolean recursionDesired)
Sets if this resolver has to send a DNS query with the RD (recursion desired) flag set.
|
DnsNameResolver |
setResolveAddressTypes(io.netty.channel.socket.InternetProtocolFamily... resolveAddressTypes)
Sets the list of the protocol families of the address resolved by
SimpleNameResolver.resolve(SocketAddress). |
DnsNameResolver |
setResolveAddressTypes(Iterable<io.netty.channel.socket.InternetProtocolFamily> resolveAddressTypes)
Sets the list of the protocol families of the address resolved by
SimpleNameResolver.resolve(SocketAddress). |
DnsNameResolver |
setTraceEnabled(boolean traceEnabled)
Sets if this resolver should generate the detailed trace information in an exception message so that
it is easier to understand the cause of resolution failure.
|
DnsNameResolver |
setTtl(int minTtl,
int maxTtl)
Sets the minimum and maximum TTL of the cached DNS resource records (in seconds).
|
public DnsNameResolver(io.netty.channel.EventLoop eventLoop,
Class<? extends io.netty.channel.socket.DatagramChannel> channelType,
DnsServerAddresses nameServerAddresses)
eventLoop - the EventLoop which will perform the communication with the DNS serverschannelType - the type of the DatagramChannel to createnameServerAddresses - the addresses of the DNS server. For each DNS query, a new stream is created from
this to determine which DNS server should be contacted for the next retry in case
of failure.public DnsNameResolver(io.netty.channel.EventLoop eventLoop,
Class<? extends io.netty.channel.socket.DatagramChannel> channelType,
InetSocketAddress localAddress,
DnsServerAddresses nameServerAddresses)
eventLoop - the EventLoop which will perform the communication with the DNS serverschannelType - the type of the DatagramChannel to createlocalAddress - the local address of the DatagramChannelnameServerAddresses - the addresses of the DNS server. For each DNS query, a new stream is created from
this to determine which DNS server should be contacted for the next retry in case
of failure.public DnsNameResolver(io.netty.channel.EventLoop eventLoop,
io.netty.channel.ChannelFactory<? extends io.netty.channel.socket.DatagramChannel> channelFactory,
DnsServerAddresses nameServerAddresses)
eventLoop - the EventLoop which will perform the communication with the DNS serverschannelFactory - the ChannelFactory that will create a DatagramChannelnameServerAddresses - the addresses of the DNS server. For each DNS query, a new stream is created from
this to determine which DNS server should be contacted for the next retry in case
of failure.public DnsNameResolver(io.netty.channel.EventLoop eventLoop,
io.netty.channel.ChannelFactory<? extends io.netty.channel.socket.DatagramChannel> channelFactory,
InetSocketAddress localAddress,
DnsServerAddresses nameServerAddresses)
eventLoop - the EventLoop which will perform the communication with the DNS serverschannelFactory - the ChannelFactory that will create a DatagramChannellocalAddress - the local address of the DatagramChannelnameServerAddresses - the addresses of the DNS server. For each DNS query, a new stream is created from
this to determine which DNS server should be contacted for the next retry in case
of failure.public int minTtl()
maxTtl(),
setTtl(int, int)public int maxTtl()
minTtl(),
setTtl(int, int)public DnsNameResolver setTtl(int minTtl, int maxTtl)
0 and Integer.MAX_VALUE, which practically tells this resolver to respect
the TTL from the DNS server.public int negativeTtl()
0, which
disables the cache for negative results.setNegativeTtl(int)public DnsNameResolver setNegativeTtl(int negativeTtl)
thisnegativeTtl()public long queryTimeoutMillis()
setQueryTimeoutMillis(long)public DnsNameResolver setQueryTimeoutMillis(long queryTimeoutMillis)
thisqueryTimeoutMillis()public List<io.netty.channel.socket.InternetProtocolFamily> resolveAddressTypes()
SimpleNameResolver.resolve(SocketAddress)
in the order of preference.
The default value depends on the value of the system property "java.net.preferIPv6Addresses".public DnsNameResolver setResolveAddressTypes(io.netty.channel.socket.InternetProtocolFamily... resolveAddressTypes)
SimpleNameResolver.resolve(SocketAddress).
Usually, both InternetProtocolFamily.IPv4 and InternetProtocolFamily.IPv6 are specified in the
order of preference. To enforce the resolve to retrieve the address of a specific protocol family, specify
only a single InternetProtocolFamily.thisresolveAddressTypes()public DnsNameResolver setResolveAddressTypes(Iterable<io.netty.channel.socket.InternetProtocolFamily> resolveAddressTypes)
SimpleNameResolver.resolve(SocketAddress).
Usually, both InternetProtocolFamily.IPv4 and InternetProtocolFamily.IPv6 are specified in the
order of preference. To enforce the resolve to retrieve the address of a specific protocol family, specify
only a single InternetProtocolFamily.thisresolveAddressTypes()public boolean isRecursionDesired()
true if and only if this resolver sends a DNS query with the RD (recursion desired) flag set.
The default value is true.setRecursionDesired(boolean)public DnsNameResolver setRecursionDesired(boolean recursionDesired)
thisisRecursionDesired()public int maxQueriesPerResolve()
8.setMaxQueriesPerResolve(int)public DnsNameResolver setMaxQueriesPerResolve(int maxQueriesPerResolve)
thismaxQueriesPerResolve()public boolean isTraceEnabled()
true.public DnsNameResolver setTraceEnabled(boolean traceEnabled)
public int maxPayloadSize()
4096 bytes.setMaxPayloadSize(int)public DnsNameResolver setMaxPayloadSize(int maxPayloadSize)
4096 bytes.thismaxPayloadSize()public DnsNameResolver setOptResourceEnabled(boolean optResourceEnabled)
public boolean isOptResourceEnabled()
public DnsNameResolver clearCache()
thisclearCache(String)public boolean clearCache(String hostname)
true if and only if there was an entry for the specified host name in the cache and
it has been removed by this methodpublic void close()
close in interface io.netty.resolver.NameResolver<InetSocketAddress>close in interface Closeableclose in interface AutoCloseableclose in class io.netty.resolver.SimpleNameResolver<InetSocketAddress>protected io.netty.channel.EventLoop executor()
executor in class io.netty.resolver.SimpleNameResolver<InetSocketAddress>protected boolean doIsResolved(InetSocketAddress address)
doIsResolved in class io.netty.resolver.SimpleNameResolver<InetSocketAddress>protected void doResolve(InetSocketAddress unresolvedAddress, io.netty.util.concurrent.Promise<InetSocketAddress> promise) throws Exception
doResolve in class io.netty.resolver.SimpleNameResolver<InetSocketAddress>Exceptionprotected void doResolveAll(InetSocketAddress unresolvedAddress, io.netty.util.concurrent.Promise<List<InetSocketAddress>> promise) throws Exception
doResolveAll in class io.netty.resolver.SimpleNameResolver<InetSocketAddress>Exceptionpublic io.netty.util.concurrent.Future<io.netty.channel.AddressedEnvelope<io.netty.handler.codec.dns.DnsResponse,InetSocketAddress>> query(io.netty.handler.codec.dns.DnsQuestion question)
public io.netty.util.concurrent.Future<io.netty.channel.AddressedEnvelope<io.netty.handler.codec.dns.DnsResponse,InetSocketAddress>> query(io.netty.handler.codec.dns.DnsQuestion question, io.netty.util.concurrent.Promise<io.netty.channel.AddressedEnvelope<? extends io.netty.handler.codec.dns.DnsResponse,InetSocketAddress>> promise)
public io.netty.util.concurrent.Future<io.netty.channel.AddressedEnvelope<io.netty.handler.codec.dns.DnsResponse,InetSocketAddress>> query(InetSocketAddress nameServerAddr, io.netty.handler.codec.dns.DnsQuestion question)
public io.netty.util.concurrent.Future<io.netty.channel.AddressedEnvelope<io.netty.handler.codec.dns.DnsResponse,InetSocketAddress>> query(InetSocketAddress nameServerAddr, io.netty.handler.codec.dns.DnsQuestion question, io.netty.util.concurrent.Promise<io.netty.channel.AddressedEnvelope<? extends io.netty.handler.codec.dns.DnsResponse,InetSocketAddress>> promise)
Copyright © 2008–2015 The Netty Project. All rights reserved.