| java.lang.Object org.apache.harmony.jndi.provider.dns.Resolver
Resolver | public class Resolver implements Runnable(Code) | | This class implements the functionality of a simple DNS resolver.
Following DNS Resource Records are supported:
- A
- NS
- CNAME
- SOA
- PTR
- MX
- TXT
- HINFO
- AAAA (TODO)
- NAPTR (TODO)
- SRV
Following DNS classes are supported:
TODO: do we need broadcasting and IP multicasting to obtain initial name
server address? TODO: network-preference feature for choosing most welcome
address for multihomed hosts (RFC 1123 point 6.1.3.4) TODO: add general IPv6
support and support for AAAA resource record
|
Inner Class :static class AnalysisReport | |
Constructor Summary | |
public | Resolver() | public | Resolver(int initialTimeout, int timeoutRetries, int maxThreads, boolean authoritativeAnswerDesired, boolean recursionDesired) Constructs a Resolver object with given initial timeout
and timeout retries. |
Method Summary | |
public void | addInitialServer(String name, String ip, int port, String zoneName) Adds initial DNS server the resolver should start with. | AnalysisReport | analyzeAnswer(Message request, Message answer) Analyzes the answer message and constructs an analysis report. | static Message | createMessageForSending(String desiredName, int recType, int recClass) Creates a new Message object and fills some of it's
standard fields. | public int | getInitialTimeout() | public int | getThreadNumberLimit() | public int | getTimeoutRetries() | public boolean | isAuthoritativeAnswerDesired() | public boolean | isRecursionDesired() | public Enumeration<ResourceRecord> | list(String name) Lists entire DNS zone using zone transfer mechanism. | public Enumeration<ResourceRecord> | lookup(String name, int[] types, int[] classes) Checks available name servers if they have any resource records related
to given name & type & class combination. | Message | queryServers(Message request, String workZone, Hashtable<Server, Object> visitedServers, boolean tcpOnly) Query available DNS servers for desired information. | public void | run() | public void | setAuthoritativeAnswerDesired(boolean authoritativeAnswerDesired) | public void | setInitialTimeout(int initialTimeout) | public void | setRecursionDesired(boolean recursionDesired) | public void | setThreadNumberLimit(int threadNumberLimit) | public void | setTimeoutRetries(int timeoutRetries) | void | startResolvingThread(String hostname, int dnsClass) Starts new resolver thread that will be searching for IP of the given
hostname. |
Resolver | public Resolver()(Code) | | Constructs a Resolver object with default initial timeout
(1 second), default timeout retries (4 times), default recursion desired
switch (true) and default authoritative answer desired
See Also: Resolver.Resolver(int,int) |
Resolver | public Resolver(int initialTimeout, int timeoutRetries, int maxThreads, boolean authoritativeAnswerDesired, boolean recursionDesired)(Code) | | Constructs a Resolver object with given initial timeout
and timeout retries. Initially the resolver will try to access DNS
servers with timeout set to initial timeout. If none of servers answer it
will double the timeout and perform the second round. The process will
continue for timeoutRetries rounds. If there is no answer
still the resolver will give up.
Parameters: initialTimeout - the initial timeout that is used during the first round (inmilliseconds) Parameters: timeoutRetries - number of rounds the Resolver should perform before giving up Parameters: authoritativeAnswerDesired - do we want to receive only authoritative answers Parameters: recursionDesired - do we want our outgoing packages to have RD but set |
addInitialServer | public void addInitialServer(String name, String ip, int port, String zoneName)(Code) | | Adds initial DNS server the resolver should start with. Trying underlying
OS services to determine IP from name.
Parameters: name - server's name Parameters: ip - server's IP address Parameters: port - port on server |
analyzeAnswer | AnalysisReport analyzeAnswer(Message request, Message answer) throws DomainProtocolException(Code) | | Analyzes the answer message and constructs an analysis report.
Parameters: request - the request has been send to the server Parameters: answer - the answer has been received Parameters: workZone - the current resolver's work zone analysis report TODO may be optimized |
createMessageForSending | static Message createMessageForSending(String desiredName, int recType, int recClass) throws DomainProtocolException(Code) | | Creates a new Message object and fills some of it's
standard fields.
created Message object |
getInitialTimeout | public int getInitialTimeout()(Code) | | Returns the initialTimeout. |
getThreadNumberLimit | public int getThreadNumberLimit()(Code) | | Returns the threadNumberLimit. |
getTimeoutRetries | public int getTimeoutRetries()(Code) | | Returns the timeoutRetries. |
isAuthoritativeAnswerDesired | public boolean isAuthoritativeAnswerDesired()(Code) | | Returns the authoritativeAnswerDesired. |
isRecursionDesired | public boolean isRecursionDesired()(Code) | | Returns the recursionDesired. |
queryServers | Message queryServers(Message request, String workZone, Hashtable<Server, Object> visitedServers, boolean tcpOnly) throws DomainProtocolException, SecurityException(Code) | | Query available DNS servers for desired information. This method doesn't
look into the local cache. Drops all answers that contains "server fail"
and "not implemented" answer codes and returns the first "good" answer.
Parameters: request - a DNS message that contains the request record Parameters: workZone - a zone that is closest known (grand-) parent of the desiredname Parameters: visitedServers - the hash list of servers, that should not be examined; thismethod also appends to this list all server that have beenvisited during execution of this method Parameters: tcpOnly - true if we want to use TCP protocol only;otherwise UDP will be tried first the message received; null if none found throws: DomainProtocolException - some domain protocol related error occured throws: SecurityException - if the resolver doesn't have the permission to use sockets |
run | public void run()(Code) | | Start background search of the address of next unresolved server hostname
|
setAuthoritativeAnswerDesired | public void setAuthoritativeAnswerDesired(boolean authoritativeAnswerDesired)(Code) | | Parameters: authoritativeAnswerDesired - The authoritativeAnswerDesired to set. |
setInitialTimeout | public void setInitialTimeout(int initialTimeout)(Code) | | Parameters: initialTimeout - The initialTimeout to set. |
setRecursionDesired | public void setRecursionDesired(boolean recursionDesired)(Code) | | Parameters: recursionDesired - The recursionDesired to set. |
setThreadNumberLimit | public void setThreadNumberLimit(int threadNumberLimit)(Code) | | Parameters: threadNumberLimit - The threadNumberLimit to set. |
setTimeoutRetries | public void setTimeoutRetries(int timeoutRetries)(Code) | | Parameters: timeoutRetries - The timeoutRetries to set. |
startResolvingThread | void startResolvingThread(String hostname, int dnsClass)(Code) | | Starts new resolver thread that will be searching for IP of the given
hostname.
Parameters: hostname - hostname to resolve Parameters: dnsClass - DNS class of host |
|
|