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 classReliableDnsClient.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 StringisResponseAcceptable(DnsMessage response)Check if the response from the system's nameserver is acceptable.protected booleanisResponseCacheable(Question q, DnsQueryResult result)Whether a response from the DNS system should be cached or not.protected DnsMessage.BuildernewQuestion(DnsMessage.Builder questionMessage)protected DnsQueryResultquery(DnsMessage.Builder q)Send a query request to the DNS system.voidsetDataSource(DnsDataSource dataSource)Set aDnsDataSourceto be used by the DnsClient.voidsetMode(ReliableDnsClient.Mode mode)Set the mode used when resolving queries.voidsetUseHardcodedDnsServers(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:AbstractDnsClientSend a query request to the DNS system.- Specified by:
queryin 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:
newQuestionin classAbstractDnsClient
-
isResponseCacheable
protected boolean isResponseCacheable(Question q, DnsQueryResult result)
Description copied from class:AbstractDnsClientWhether a response from the DNS system should be cached or not.- Overrides:
isResponseCacheablein 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 returnnullif the response is acceptable, or a String describing why it is not acceptable. If the response is not acceptable thenReliableDnsClientwill fall back to resolve the query iteratively.- Parameters:
response- the response we got from the system's nameserver.- Returns:
nullif the response is acceptable, or a String if not.
-
setDataSource
public void setDataSource(DnsDataSource dataSource)
Description copied from class:AbstractDnsClientSet aDnsDataSourceto 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:
setDataSourcein 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)
-
-