public class Client extends Object
Modifier and Type | Field and Description |
---|---|
protected int |
bufferSize
The buffer size for dns replies.
|
protected DNSCache |
cache
The internal DNS cache.
|
protected Random |
random
The internal random class for sequence generation.
|
protected int |
timeout
DNS timeout.
|
Constructor and Description |
---|
Client()
Create a new DNS client without any caching.
|
Client(DNSCache cache)
Create a new DNS client with the given DNS cache.
|
Client(Map<Question,DNSMessage> cache) |
Modifier and Type | Method and Description |
---|---|
String[] |
findDNS()
Retrieve a list of currently configured DNS servers.
|
protected String[] |
findDNSByExec()
Try to retrieve the list of dns server by executing getprop.
|
protected String[] |
findDNSByReflection()
Try to retrieve the list of dns server by calling SystemProperties.
|
int |
getTimeout()
Retrieve the current dns query timeout, in milliseconds.
|
DNSMessage |
query(Question q)
Query the system DNS server for one entry.
|
DNSMessage |
query(Question q,
String host)
Query a specific server for one entry.
|
DNSMessage |
query(Question q,
String host,
int port)
Query a specific server for one entry.
|
DNSMessage |
query(String name,
Record.TYPE type)
Query the system nameservers for a single entry of the class IN
(which is used for MX, SRV, A, AAAA and most other RRs).
|
DNSMessage |
query(String name,
Record.TYPE type,
Record.CLASS clazz)
Query the system nameservers for a single entry of any class.
|
DNSMessage |
query(String name,
Record.TYPE type,
Record.CLASS clazz,
String host)
Query a nameserver for a single entry.
|
DNSMessage |
query(String name,
Record.TYPE type,
Record.CLASS clazz,
String host,
int port)
Query a nameserver for a single entry.
|
void |
setTimeout(int timeout)
Change the dns query timeout for all future queries.
|
protected Random random
protected int bufferSize
protected int timeout
protected DNSCache cache
public Client(DNSCache cache)
cache
- The backend DNS cache.public Client(Map<Question,DNSMessage> cache)
public Client()
public int getTimeout()
public void setTimeout(int timeout)
timeout
- new dns query timeout in milliseconds.public DNSMessage query(String name, Record.TYPE type, Record.CLASS clazz, String host, int port) throws IOException
name
- The DNS name to request.type
- The DNS type to request (SRV, A, AAAA, ...).clazz
- The class of the request (usually IN for Internet).host
- The DNS server host.port
- The DNS server port.IOException
- On IO Errors.public DNSMessage query(String name, Record.TYPE type, Record.CLASS clazz, String host) throws IOException
name
- The DNS name to request.type
- The DNS type to request (SRV, A, AAAA, ...).clazz
- The class of the request (usually IN for Internet).host
- The DNS server host.IOException
- On IO Errors.public DNSMessage query(String name, Record.TYPE type, Record.CLASS clazz)
name
- The DNS name to request.type
- The DNS type to request (SRV, A, AAAA, ...).clazz
- The class of the request (usually IN for Internet).public DNSMessage query(String name, Record.TYPE type)
name
- The DNS name to request.type
- The DNS type to request (SRV, A, AAAA, ...).public DNSMessage query(Question q, String host) throws IOException
q
- The question section of the DNS query.host
- The dns server host.IOException
- On IOErrors.public DNSMessage query(Question q, String host, int port) throws IOException
q
- The question section of the DNS query.host
- The dns server host.port
- the dns port.IOException
- On IOErrors.public DNSMessage query(Question q)
q
- The question section of the DNS query.public String[] findDNS()
protected String[] findDNSByExec()
protected String[] findDNSByReflection()
Copyright © 2014–2016. All rights reserved.