|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.lavantech.net.dns.DNSLookup
DNSLookup class looks up a record on a given DNS Server. If you want to do simple DNS lookup, take a look at SimpleDNSLookup class. The lookup is performed when the class is constructed. Here is an example where the class is used to get all IP Address (A Record) for www.hotmail.com.
// QTYPE_A asks for the ARecord(Address Record).
// QCLASS_IN is for Internet class.
// null is passed for server name. If null is passed the name server setting of the system is used.
DNSLookup dnsLookup = new DNSLookup("www.hotmail.com", DNSLookup.QTYPE_A,
DNSLookup.QCLASS_IN, 1000, null);
// Get all Address Records.
ResourceRecord[] ansRecords = dnsLookup.getAnswerRecords();
// Print all the Address Records.
for(int i=0; i < ansRecords.length; i++)
{
if(ansRecords[i] instanceof ARecord)
System.out.println(((ARecord)ansRecords[i]).getInetAddress().getHostAddress());
}
SimpleDNSLookup
Field Summary | |
static int |
INTERNAL_BUFFER
Size of internal buffer used to field the response from the DNS server. |
static int |
QCLASS_ANY
Query class for any scheme of record system. |
static int |
QCLASS_CHAOS
Query class for Chaos scheme of record system. |
static int |
QCLASS_HESIOD
Query class for Hesiod scheme of record system. |
static int |
QCLASS_IN
Query class for Internet scheme of record system. |
static int |
QTYPE_A
Query type value for Address Record. |
static int |
QTYPE_A6
Query type value for IPV6 Address Record(Newer version of A6). |
static int |
QTYPE_AAAA
Query type value for IPv6 Address Record. |
static int |
QTYPE_ANY
Query type value for All Records. |
static int |
QTYPE_CNAME
Query type value for Canonical Name Record. |
static int |
QTYPE_MX
Query type value for Mail Exchange Record. |
static int |
QTYPE_NS
Query type value for Name Server Record. |
static int |
QTYPE_PTR
Query type value for Pointer Record. |
static int |
QTYPE_SOA
Query type value for Start Of Authority Record. |
static int |
QTYPE_TXT
Query type value for Text Record. |
static int |
QTYPE_WKS
Query type value for Well Known Services Record. |
Constructor Summary | |
DNSLookup(java.lang.String query,
int qtype,
int qclass,
int timeout,
java.lang.String server)
DNSLookup Constructor looks up a requested record on a given server. |
Method Summary | |
A6Record[] |
getA6Records()
Returns all A6 records received in the response. |
AAAARecord[] |
getAAAARecords()
Returns all AAAA records received in the response. |
ResourceRecord[] |
getAdditionalRecords()
Returns Resource Records extracted from the Additional Section of the response. |
ResourceRecord[] |
getAnswerRecords()
Returns Resource Records extracted from the Answer Section of the response. |
ARecord[] |
getARecords()
Returns all A records received in the response. |
ResourceRecord[] |
getAuthorityRecords()
Returns Resource Records extracted from the Authority Section of the response. |
CNAMERecord[] |
getCNAMERecords()
Returns all CNAME records received in the response. |
MXRecord[] |
getMXRecords()
Returns all MX records received in the response. |
NSRecord[] |
getNSRecords()
Returns all NS records received in the response. |
PTRRecord[] |
getPTRRecords()
Returns all PTR records received in the response. |
QuestionRecord |
getQuestionRecord()
Returns the Question Record that is sent back in the response. |
SOARecord[] |
getSOARecords()
Returns all SOA records received in the response. |
TXTRecord[] |
getTXTRecords()
Returns all TXT records received in the response. |
WKSRecord[] |
getWKSRecords()
Returns all WKS records received in the response. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int QTYPE_A
public static final int QTYPE_NS
public static final int QTYPE_CNAME
public static final int QTYPE_SOA
public static final int QTYPE_WKS
public static final int QTYPE_PTR
public static final int QTYPE_MX
public static final int QTYPE_TXT
public static final int QTYPE_AAAA
public static final int QTYPE_A6
public static final int QTYPE_ANY
public static final int QCLASS_IN
public static final int QCLASS_CHAOS
public static final int QCLASS_HESIOD
public static final int QCLASS_ANY
public static int INTERNAL_BUFFER
Constructor Detail |
public DNSLookup(java.lang.String query, int qtype, int qclass, int timeout, java.lang.String server) throws java.lang.Exception
query
- The string indicating the hostname/domainname/ipaddress for which
the record lookup will be done.qtype
- The Record type that needs to be looked up. QTYPE_A is for address,
QTYPE_NS if for Name server, QTYPE_MX for Mail Exchange....qclass
- The Record scheme on which the lookup should be performed. The
most widely used scheme is Internet ( QCLASS_IN ).timeout
- The Timeout in milliseconds to wait for the response from the server.
If reponse is not recived with the timeout period, a SocketTimeoutException
is thrown.server
- The Domain Name Server on which the lookup has to be performed. This could be
a hostname or a IP address. If null can be passed, the DNS setting from the
system would be used. If a system property dns.server is set, this would be used.
The system property can be set while starting the Java VM with the option
-Ddns.server="DNS name"
java.net.SocketTimeoutException
- If a reponse is not received within the timeout period.
java.lang.Exception
- If the Name Server can't be determined or any other internal problem occurs.Method Detail |
public QuestionRecord getQuestionRecord()
public ResourceRecord[] getAnswerRecords()
public ResourceRecord[] getAuthorityRecords()
public ResourceRecord[] getAdditionalRecords()
public A6Record[] getA6Records()
public AAAARecord[] getAAAARecords()
public ARecord[] getARecords()
public CNAMERecord[] getCNAMERecords()
public MXRecord[] getMXRecords()
public NSRecord[] getNSRecords()
public PTRRecord[] getPTRRecords()
public SOARecord[] getSOARecords()
public WKSRecord[] getWKSRecords()
public TXTRecord[] getTXTRecords()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |