Package org.minidns
Class DnsClient
- java.lang.Object
-
- org.minidns.AbstractDnsClient
-
- org.minidns.DnsClient
-
public class DnsClient extends AbstractDnsClient
A minimal DNS client for SRV/A/AAAA/NS and CNAME lookups, with IDN support. This circumvents the missing javax.naming package on android.
-
-
Nested Class Summary
-
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
-
-
Method Summary
-
Methods inherited from class org.minidns.AbstractDnsClient
getCache, getCachedIPv4AddressesFor, getCachedIPv4NameserverAddressesFor, getCachedIPv6AddressesFor, getCachedIPv6NameserverAddressesFor, getCachedNameserverRecordsFor, getDataSource, getPreferedIpVersion, getQueryFor, isResponseCacheable, query, query, query, query, query, query, query, query, query, query, query, queryAsync, queryAsync, queryAsync, queryAsync, setDataSource, setDefaultIpVersion, setPreferedIpVersion
-
-
-
-
Method Detail
-
newQuestion
protected DnsMessage.Builder newQuestion(DnsMessage.Builder message)
- Specified by:
newQuestion
in classAbstractDnsClient
-
query
public DnsQueryResult query(DnsMessage.Builder queryBuilder) throws IOException
Description copied from class:AbstractDnsClient
Send a query request to the DNS system.- Specified by:
query
in classAbstractDnsClient
- Parameters:
queryBuilder
- The query to send to the server.- Returns:
- The response (or null).
- Throws:
IOException
- if an IO error occurs.
-
queryAsync
protected MiniDnsFuture<DnsQueryResult,IOException> queryAsync(DnsMessage.Builder queryBuilder)
Description copied from class:AbstractDnsClient
Default implementation of an asynchronous DNS query which just wraps the synchronous case.Subclasses override this method to support true asynchronous queries.
- Overrides:
queryAsync
in classAbstractDnsClient
- Parameters:
queryBuilder
- the query.- Returns:
- a future for this query.
-
findDNS
public static List<String> findDNS()
Retrieve a list of currently configured DNS servers IP addresses. This method does verify that only IP addresses are returned and nothing else (e.g. DNS names).The addresses are discovered by using one (or more) of the configured
DnsServerLookupMechanism
s.- Returns:
- A list of DNS server IP addresses configured for this system.
-
findDnsAddresses
public static List<InetAddress> findDnsAddresses()
Retrieve a list of currently configured DNS server addresses.Note that unlike
findDNS()
, the list returned by this method will take the IP version setting into account, and order the list by the preferred address types (IPv4/v6). The returned list is modifiable.- Returns:
- A list of DNS server addresses.
- See Also:
findDNS()
-
addDnsServerLookupMechanism
public static void addDnsServerLookupMechanism(DnsServerLookupMechanism dnsServerLookup)
-
removeDNSServerLookupMechanism
public static boolean removeDNSServerLookupMechanism(DnsServerLookupMechanism dnsServerLookup)
-
addBlacklistedDnsServer
public static boolean addBlacklistedDnsServer(String dnsServer)
-
removeBlacklistedDnsServer
public static boolean removeBlacklistedDnsServer(String dnsServer)
-
isAskForDnssec
public boolean isAskForDnssec()
-
setAskForDnssec
public void setAskForDnssec(boolean askForDnssec)
-
isDisableResultFilter
public boolean isDisableResultFilter()
-
setDisableResultFilter
public void setDisableResultFilter(boolean disableResultFilter)
-
isUseHardcodedDnsServersEnabled
public boolean isUseHardcodedDnsServersEnabled()
-
setUseHardcodedDnsServers
public void setUseHardcodedDnsServers(boolean useHardcodedDnsServers)
-
getRandomHardcodedIpv4DnsServer
public InetAddress getRandomHardcodedIpv4DnsServer()
-
getRandomHarcodedIpv6DnsServer
public InetAddress getRandomHarcodedIpv6DnsServer()
-
getReverseIpLookupQuestionFor
public static Question getReverseIpLookupQuestionFor(Inet4Address inet4Address)
-
getReverseIpLookupQuestionFor
public static Question getReverseIpLookupQuestionFor(Inet6Address inet6Address)
-
getReverseIpLookupQuestionFor
public static Question getReverseIpLookupQuestionFor(InetAddress inetAddress)
-
-