Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

*) next step of restructuring for new crawlers - adding function isSupportedProcotol to plasmaCrawlLoader.java - disabling robots.txt check for protocols other than http(s)

thelie3f013660608
diff --git a/source/de/anomic/plasma/plasmaCrawlEURL.java b/source/de/anomic/plasma/plasmaCrawlEURL.java
index 7c692d271..933b5c127 100644
--- a/source/de/anomic/plasma/plasmaCrawlEURL.java
+++ b/source/de/anomic/plasma/plasmaCrawlEURL.java
@@ -70,6 +70,7 @@ public class plasmaCrawlEURL extends indexURL {
// invalid urls
public static final String DENIED_URL_NULL = "denied_(url_null)";
public static final String DENIED_MALFORMED_URL = "denied_(malformed_url)";
+ public static final String DENIED_UNSUPPORTED_PROTOCOL = "denied_(unsupported_protocol)";
public static final String DENIED_PRIVATE_IP_ADDRESS = "denied_(private_ip_address)";
public static final String DENIED_LOOPBACK_IP_ADDRESS = "denied_(loopback_ip_address)";
public static final String DENIED_CACHEFILE_PATH_TOO_LONG = "denied_(cachefile_path_too_long)";
diff --git a/source/de/anomic/plasma/plasmaCrawlLoader.java b/source/de/anomic/plasma/plasmaCrawlLoader.java
index 63d10555d..df4887a96 100644
--- a/source/de/anomic/plasma/plasmaCrawlLoader.java
+++ b/source/de/anomic/plasma/plasmaCrawlLoader.java
@@ -121,6 +121,15 @@ public final class plasmaCrawlLoader extends Thread {
public void setPoolConfig(GenericKeyedObjectPool.Config newConfig) {
this.crawlwerPool.setConfig(newConfig);
}
+
+ public boolean isSupportedProtocol(String protocol) {
+ if ((protocol == null) || (protocol.length() == 0)) return false;
+
+ // TODO: read the supported protocols out from a config file
+ protocol = protocol.trim().toLowerCase();
+ return protocol.equals("http") ||
+ protocol.equals("https");
+ }
public void close() {
try {
diff --git a/source/de/anomic/plasma/plasmaCrawlStacker.java b/source/de/anomic/plasma/plasmaCrawlStacker.java
index 64cc22145..0b444dc50 100644
--- a/source/de/anomic/plasma/plasmaCrawlStacker.java
+++ b/source/de/anomic/plasma/plasmaCrawlStacker.java
@@ -251,6 +251,9 @@ public final class plasmaCrawlStacker {
long startTime = System.currentTimeMillis();
String reason = null; // failure reason
+
+ // getting the initiator peer hash
+ if ((initiatorHash == null) || (initiatorHash.length() == 0)) initiatorHash = indexURL.dummyHash;
// strange errors
if (nexturlString == null) {
@@ -258,12 +261,9 @@ public final class plasmaCrawlStacker {
this.log.logSevere("Wrong URL in stackCrawl: url=null");
return reason;
}
-
- // getting the initiator peer hash
- if ((initiatorHash == null) || (initiatorHash.length() == 0)) initiatorHash = indexURL.dummyHash;
// getting the referer url and url hash
- URL nexturl = null, referrerURL = null;
+ URL referrerURL = null;
if (referrerString != null) {
try {
referrerURL = new URL(referrerString);
@@ -273,8 +273,9 @@ public final class plasmaCrawlStacker {
}
}
String referrerHash = (referrerString==null)?null:indexURL.urlHash(referrerString);
-
+
// check for malformed urls
+ URL nexturl = null;
try {
nexturl = new URL(nexturlString);
} catch (MalformedURLException e) {
@@ -283,6 +284,15 @@ public final class plasmaCrawlStacker {
". Stack processing time: " + (System.currentTimeMillis()-startTime) + "ms");
return reason;
}
+
+ // check if the protocol is supported
+ String urlProtocol = nexturl.getProtocol();
+ if (!this.sb.cacheLoader.isSupportedProtocol(urlProtocol)) {
+ reason = plasmaCrawlEURL.DENIED_UNSUPPORTED_PROTOCOL;
+ this.log.logSevere("Unsupported protocol in URL '" + nexturlString + "'. " +
+ "Stack processing time: " + (System.currentTimeMillis()-startTime) + "ms");
+ return reason;
+ }
// check if ip is local ip address
checkInterruption();
@@ -382,9 +392,9 @@ public final class plasmaCrawlStacker {
return reason;
}
- // checking robots.txt
+ // checking robots.txt for http(s) resources
checkInterruption();
- if (robotsParser.isDisallowed(nexturl)) {
+ if ((urlProtocol.equals("http") || urlProtocol.equals("https")) && robotsParser.isDisallowed(nexturl)) {
reason = plasmaCrawlEURL.DENIED_ROBOTS_TXT;
this.log.logFine("Crawling of URL '" + nexturlString + "' disallowed by robots.txt. " +