com.buzzsurf.dns
Class DNSJavaNameService
java.lang.Object
|
+--com.buzzsurf.dns.DNSJavaNameService
- All Implemented Interfaces:
- sun.net.spi.nameservice.NameService
- public class DNSJavaNameService
- extends java.lang.Object
- implements sun.net.spi.nameservice.NameService
This class implements a Name Service Provider, which Java can use
(starting with version 1.4), to perform DNS resolutions instead of using
standard native calls. Doing your own name resolutions was possible
before Java 1.4, but it required custom code, and you couldn't use it
in the URLConnection classes because they provide no access to the
underlying socket.
This Name Service Provider uses the dnsjava package
(http://www.xbill.org/dnsjava).
Important: To use this service, you must set the following system property:
- sun.net.spi.nameservice.provider.1=dns,dnsjava
The following system properties are optional and effect performance
of the dns resolver:
- sun.net.spi.nameservice.nameservers=
Set this property to specify your name servers. (If you do not set it,
dnsjava will attempt to determine your name servers itself. It isn't
always successful, so it's a good idea to set this property!!)
- dnsjava.load.balance= Default: false. If true, dnsjava
will query your list of DNS server in a round-robin fashion
- dnsjava.use.tcp= Default: false. If true, dnsjava will
communicate with your DNS server using TCP insead of UDP.
- dnsjava.timeout= Default: 20. The time in seconds to wait
for a resoponse before giving up.
- dnsjava.retries= Default: 3. The number of times to attempt to
contact the DNS server before giving up.
- Version:
- 0.9
- Author:
- Paul Cowan (pwc21@yahoo.com)
|
Field Summary |
protected org.xbill.DNS.ExtendedResolver |
resolver
|
|
Method Summary |
java.lang.String |
getHostByAddr(byte[] ip)
Finds PTR records (reverse dns lookups) for the ip address |
byte[][] |
lookupAllHostAddr(java.lang.String name)
Finds A records (ip addresses) for the host name. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
resolver
protected org.xbill.DNS.ExtendedResolver resolver
DNSJavaNameService
protected DNSJavaNameService()
throws java.net.UnknownHostException
- Constructor for DNSJavaNameService. Reads all available property and initializes dnsjava.
This should throw an UnknownHostException if it is not able to find your name servers.
lookupAllHostAddr
public byte[][] lookupAllHostAddr(java.lang.String name)
throws java.net.UnknownHostException
- Finds A records (ip addresses) for the host name.
- Specified by:
lookupAllHostAddr in interface sun.net.spi.nameservice.NameService
- Returns:
- All the ip addresses found for the host name.
java.net.UnknownHostException
getHostByAddr
public java.lang.String getHostByAddr(byte[] ip)
throws java.net.UnknownHostException
- Finds PTR records (reverse dns lookups) for the ip address
- Specified by:
getHostByAddr in interface sun.net.spi.nameservice.NameService
- Returns:
- The host name found for the ip address.
java.net.UnknownHostException