public class ReliableDnsClient extends AbstractDnsClient
Modifier and Type | Class and Description |
---|---|
static class |
ReliableDnsClient.Mode |
AbstractDnsClient.IpVersionSetting
cache, dataSource, DEFAULT_CACHE, DEFAULT_IP_VERSION_SETTING, insecureRandom, ipVersionSetting, LOGGER, random
Constructor and Description |
---|
ReliableDnsClient() |
ReliableDnsClient(DnsCache dnsCache) |
Modifier and Type | Method and Description |
---|---|
protected String |
isResponseAcceptable(DnsMessage response)
Check if the response from the system's nameserver is acceptable.
|
protected boolean |
isResponseCacheable(Question q,
DnsMessage dnsMessage)
Whether a response from the DNS system should be cached or not.
|
protected DnsMessage.Builder |
newQuestion(DnsMessage.Builder questionMessage) |
protected DnsMessage |
query(DnsMessage.Builder q)
Send a query request to the DNS system.
|
void |
setDataSource(DnsDataSource dataSource)
Set a
DnsDataSource to be used by the DnsClient. |
void |
setMode(ReliableDnsClient.Mode mode)
Set the mode used when resolving queries.
|
getCache, getCachedIPv4AddressesFor, getCachedIPv4NameserverAddressesFor, getCachedIPv6AddressesFor, getCachedIPv6NameserverAddressesFor, getCachedNameserverRecordsFor, getDataSource, getPreferedIpVersion, getQueryFor, query, query, query, query, query, query, query, query, query, query, query, queryAsync, queryAsync, queryAsync, queryAsync, queryAsync, setDefaultIpVersion, setPreferedIpVersion
public ReliableDnsClient(DnsCache dnsCache)
public ReliableDnsClient()
protected DnsMessage query(DnsMessage.Builder q) throws IOException
AbstractDnsClient
query
in class AbstractDnsClient
q
- The query to send to the server.IOException
- if an IO error occurs.protected DnsMessage.Builder newQuestion(DnsMessage.Builder questionMessage)
newQuestion
in class AbstractDnsClient
protected boolean isResponseCacheable(Question q, DnsMessage dnsMessage)
AbstractDnsClient
isResponseCacheable
in class AbstractDnsClient
q
- The question the response message should answer.dnsMessage
- The response message received using the DNS client.protected String isResponseAcceptable(DnsMessage response)
null
if the response
is acceptable, or a String describing why it is not acceptable. If the response is not acceptable then
ReliableDnsClient
will fall back to resolve the query iteratively.response
- the response we got from the system's nameserver.null
if the response is acceptable, or a String if not.public void setDataSource(DnsDataSource dataSource)
AbstractDnsClient
DnsDataSource
to be used by the DnsClient.
The default implementation will direct all queries directly to the Internet.
This can be used to define a non-default handling for outgoing data. This can be useful to redirect the requests
to a proxy or to modify requests after or responses before they are handled by the DnsClient implementation.setDataSource
in class AbstractDnsClient
dataSource
- An implementation of DNSDataSource that shall be used.public void setMode(ReliableDnsClient.Mode mode)
mode
- the mode to use.