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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static boolean
addBlacklistedDnsServer(java.lang.String dnsServer)
static void
addDnsServerLookupMechanism(DnsServerLookupMechanism dnsServerLookup)
static java.util.List<java.lang.String>
findDNS()
Retrieve a list of currently configured DNS servers IP addresses.static java.util.List<java.net.InetAddress>
findDnsAddresses()
Retrieve a list of currently configured DNS server addresses.java.net.InetAddress
getRandomHarcodedIpv6DnsServer()
java.net.InetAddress
getRandomHardcodedIpv4DnsServer()
static Question
getReverseIpLookupQuestionFor(java.net.Inet4Address inet4Address)
static Question
getReverseIpLookupQuestionFor(java.net.Inet6Address inet6Address)
static Question
getReverseIpLookupQuestionFor(java.net.InetAddress inetAddress)
boolean
isAskForDnssec()
boolean
isDisableResultFilter()
boolean
isUseHardcodedDnsServersEnabled()
protected DnsMessage.Builder
newQuestion(DnsMessage.Builder message)
DnsQueryResult
query(DnsMessage.Builder queryBuilder)
Send a query request to the DNS system.protected MiniDnsFuture<DnsQueryResult,java.io.IOException>
queryAsync(DnsMessage.Builder queryBuilder)
Default implementation of an asynchronous DNS query which just wraps the synchronous case.static boolean
removeBlacklistedDnsServer(java.lang.String dnsServer)
static boolean
removeDNSServerLookupMechanism(DnsServerLookupMechanism dnsServerLookup)
void
setAskForDnssec(boolean askForDnssec)
void
setDisableResultFilter(boolean disableResultFilter)
void
setUseHardcodedDnsServers(boolean useHardcodedDnsServers)
-
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 java.io.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:
java.io.IOException
- if an IO error occurs.
-
queryAsync
protected MiniDnsFuture<DnsQueryResult,java.io.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 java.util.List<java.lang.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 java.util.List<java.net.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(java.lang.String dnsServer)
-
removeBlacklistedDnsServer
public static boolean removeBlacklistedDnsServer(java.lang.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 java.net.InetAddress getRandomHardcodedIpv4DnsServer()
-
getRandomHarcodedIpv6DnsServer
public java.net.InetAddress getRandomHarcodedIpv6DnsServer()
-
getReverseIpLookupQuestionFor
public static Question getReverseIpLookupQuestionFor(java.net.Inet4Address inet4Address)
-
getReverseIpLookupQuestionFor
public static Question getReverseIpLookupQuestionFor(java.net.Inet6Address inet6Address)
-
getReverseIpLookupQuestionFor
public static Question getReverseIpLookupQuestionFor(java.net.InetAddress inetAddress)
-
-