Package org.minidns.iterative
Class ReliableDnsClient
- java.lang.Object
-
- org.minidns.AbstractDnsClient
-
- org.minidns.iterative.ReliableDnsClient
-
- Direct Known Subclasses:
DnssecClient
public class ReliableDnsClient extends AbstractDnsClient
A DNS client using a reliable strategy. First the configured resolver of the system are used, then, in case there is no answer, a fall back to iterative resolving is performed.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ReliableDnsClient.Mode
-
Nested classes/interfaces inherited from class org.minidns.AbstractDnsClient
AbstractDnsClient.IpVersionSetting
-
-
Field Summary
-
Fields inherited from class org.minidns.AbstractDnsClient
cache, dataSource, DEFAULT_CACHE, DEFAULT_IP_VERSION_SETTING, insecureRandom, ipVersionSetting, LOGGER, random
-
-
Constructor Summary
Constructors Constructor Description ReliableDnsClient()
ReliableDnsClient(DnsCache dnsCache)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
isResponseAcceptable(DnsMessage response)
Check if the response from the system's nameserver is acceptable.protected boolean
isResponseCacheable(Question q, DnsQueryResult result)
Whether a response from the DNS system should be cached or not.protected DnsMessage.Builder
newQuestion(DnsMessage.Builder questionMessage)
protected DnsQueryResult
query(DnsMessage.Builder q)
Send a query request to the DNS system.void
setDataSource(DnsDataSource dataSource)
Set aDnsDataSource
to be used by the DnsClient.void
setMode(ReliableDnsClient.Mode mode)
Set the mode used when resolving queries.void
setUseHardcodedDnsServers(boolean useHardcodedDnsServers)
-
Methods inherited from class org.minidns.AbstractDnsClient
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
-
-
-
-
Constructor Detail
-
ReliableDnsClient
public ReliableDnsClient(DnsCache dnsCache)
-
ReliableDnsClient
public ReliableDnsClient()
-
-
Method Detail
-
query
protected DnsQueryResult query(DnsMessage.Builder q) throws IOException
Description copied from class:AbstractDnsClient
Send a query request to the DNS system.- Specified by:
query
in classAbstractDnsClient
- Parameters:
q
- The query to send to the server.- Returns:
- The response (or null).
- Throws:
IOException
- if an IO error occurs.
-
newQuestion
protected DnsMessage.Builder newQuestion(DnsMessage.Builder questionMessage)
- Specified by:
newQuestion
in classAbstractDnsClient
-
isResponseCacheable
protected boolean isResponseCacheable(Question q, DnsQueryResult result)
Description copied from class:AbstractDnsClient
Whether a response from the DNS system should be cached or not.- Overrides:
isResponseCacheable
in classAbstractDnsClient
- Parameters:
q
- The question the response message should answer.result
- The DNS query result.- Returns:
- True, if the response should be cached, false otherwise.
-
isResponseAcceptable
protected String isResponseAcceptable(DnsMessage response)
Check if the response from the system's nameserver is acceptable. Must returnnull
if the response is acceptable, or a String describing why it is not acceptable. If the response is not acceptable thenReliableDnsClient
will fall back to resolve the query iteratively.- Parameters:
response
- the response we got from the system's nameserver.- Returns:
null
if the response is acceptable, or a String if not.
-
setDataSource
public void setDataSource(DnsDataSource dataSource)
Description copied from class:AbstractDnsClient
Set aDnsDataSource
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.- Overrides:
setDataSource
in classAbstractDnsClient
- Parameters:
dataSource
- An implementation of DNSDataSource that shall be used.
-
setMode
public void setMode(ReliableDnsClient.Mode mode)
Set the mode used when resolving queries.- Parameters:
mode
- the mode to use.
-
setUseHardcodedDnsServers
public void setUseHardcodedDnsServers(boolean useHardcodedDnsServers)
-
-