if(dnsName == null) {
curi.setFetchStatus(S_UNFETCHABLE_URI);
return;
}
CrawlHost targetHost = getServerCache().getHostFor(dnsName);
if (isQuadAddress(curi, dnsName, targetHost)) {
// We're done processing.
return;
}
// Do actual DNS lookup.
curi.setFetchBeginTime(System.currentTimeMillis());
// Try to get the records for this host (assume domain name)
// TODO: Bug #935119 concerns potential hang here
String lookupName = dnsName.endsWith(".") ? dnsName : dnsName + ".";
try {
rrecordSet = (new Lookup(lookupName, TypeType, ClassType)).run();
} catch (TextParseException e) {
rrecordSet = null;
}
curi.setContentType("text/dns");
if (rrecordSet != null) {
if (logger.isLoggable(Level.FINE)) {
logger.fine("Found recordset for " + lookupName);
}
storeDNSRecord(curi, dnsName, targetHost, rrecordSet);
} else {
if (logger.isLoggable(Level.FINE)) {
logger.fine("Failed find of recordset for " + lookupName);
}
if (getAcceptNonDnsResolves()||"localhost".equals(dnsName)) {
// Do lookup that bypasses javadns.
InetAddress address = null;
try {
address = InetAddress.getByName(dnsName);
} catch (UnknownHostException e1) {
address = null;
}
if (address != null) {
targetHost.setIP(address, DEFAULT_TTL_FOR_NON_DNS_RESOLVES);
curi.setFetchStatus(S_GETBYNAME_SUCCESS);
if (logger.isLoggable(Level.FINE)) {
logger.fine("Found address for " + dnsName +
" using native dns.");
}