public class DNSResolver
extends java.lang.Object
setDefaultDNSServers(String[])
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_RETRIES_PER_DNS_SERVER
The default number of resolve-retries per DNS server.
|
static int |
DEFAULT_TIMEOUT_PER_DNS_SERVER_MILLIS
The default resolve-timeout which is applied per DNS server.
|
Constructor and Description |
---|
DNSResolver()
Create a new DNS resolver which uses the default DNS server(s).
|
DNSResolver(java.lang.String[] dnsServers)
Create a new DNS resolver which uses custom DNS server(s).
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String[] |
getDefaultDNSServers()
Get the default DNS servers which are applied for all new instances of the DNSResolver.
|
java.lang.String[] |
getDNSServers()
Get the DNS servers which are set for this DNS resolver.
|
static java.lang.String[] |
getOSDefaultDNSServers()
This method works for Java 8 only: Get the default DNS servers which are configured at operating system level.
|
long |
getResolveTimeMillis()
Get the local measured resolve time of the last performed resolve.
|
java.util.ArrayList<org.xbill.DNS.ARecord> |
resolveRecordTypeA(java.lang.String hostname)
Resolve all IPv4 addresses for a hostname.
|
java.util.ArrayList<org.xbill.DNS.AAAARecord> |
resolveRecordTypeAAAA(java.lang.String hostname)
Resolve all IPv6 addresses for a hostname.
|
org.xbill.DNS.CNAMERecord |
resolveRecordTypeCNAME(java.lang.String hostname)
Resolve a DNS canonical name for a hostname.
|
static void |
setDefaultDNSServers(java.lang.String[] defaultDNSServers)
Set or update the default DNS servers which are applied for all new instances of the DNSResolver.
|
void |
setResolveRetriesPerDNSServer(int resolveRetries)
Set the number of resolve-retries per DNS server.
|
void |
setResolveTimeoutPerDNSServerMillis(int resolveTimeoutMillis)
Set the DNS resolve timeout applied per DNS server.
|
public static int DEFAULT_TIMEOUT_PER_DNS_SERVER_MILLIS
setResolveTimeoutPerDNSServerMillis(int)
public static int DEFAULT_RETRIES_PER_DNS_SERVER
setResolveRetriesPerDNSServer(int)
public DNSResolver() throws java.net.UnknownHostException
java.lang.RuntimeException
- if no default DNS servers have setjava.net.UnknownHostException
- if a failure occurred when initializing the resolver.setDefaultDNSServers(String[])
public DNSResolver(java.lang.String[] dnsServers) throws java.net.UnknownHostException
dnsServers
- an array of custom DNS serversjava.net.UnknownHostException
- if a failure occurred when initializing the resolver.public static void setDefaultDNSServers(java.lang.String[] defaultDNSServers)
defaultDNSServers
- the default DNS servers which are applied for all new instances of the DNSResolvergetOSDefaultDNSServers()
public static java.lang.String[] getDefaultDNSServers()
setDefaultDNSServers(String[])
public void setResolveTimeoutPerDNSServerMillis(int resolveTimeoutMillis)
resolveTimeoutMillis
- the resolve timeout in milliseconds applied per DNS serverDNSResolveTimeoutException
,
DEFAULT_TIMEOUT_PER_DNS_SERVER_MILLIS
public void setResolveRetriesPerDNSServer(int resolveRetries)
resolveRetries
- the number of resolve-retries per DNSDEFAULT_RETRIES_PER_DNS_SERVER
public java.util.ArrayList<org.xbill.DNS.ARecord> resolveRecordTypeA(java.lang.String hostname) throws org.xbill.DNS.TextParseException, DNSResolveTimeoutException, java.net.UnknownHostException
hostname
- the hostname to resolveorg.xbill.DNS.TextParseException
- if the hostname is invalidDNSResolveTimeoutException
- if the DNS resolver timeout is exceededjava.net.UnknownHostException
- if no DNS A records are received from the DNS server(s)java.lang.RuntimeException
- if an invalid DNS record type is received from the server(s)public java.util.ArrayList<org.xbill.DNS.AAAARecord> resolveRecordTypeAAAA(java.lang.String hostname) throws org.xbill.DNS.TextParseException, DNSResolveTimeoutException, java.net.UnknownHostException
hostname
- the hostname to resolveorg.xbill.DNS.TextParseException
- if the hostname is invalidDNSResolveTimeoutException
- if the DNS resolver timeout is exceededjava.net.UnknownHostException
- if no DNS AAAA records are received from the DNS server(s)java.lang.RuntimeException
- if an invalid DNS record type is received from the server(s)public org.xbill.DNS.CNAMERecord resolveRecordTypeCNAME(java.lang.String hostname) throws org.xbill.DNS.TextParseException, DNSResolveTimeoutException
hostname
- the hostname to resolveorg.xbill.DNS.TextParseException
- if the hostname is invalidDNSResolveTimeoutException
- if the DNS resolver timeout is exceededjava.lang.RuntimeException
- if an invalid DNS record type is received from the server(s)public long getResolveTimeMillis()
public java.lang.String[] getDNSServers()
public static java.lang.String[] getOSDefaultDNSServers()