Skip to content

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

seedDB helpers

borg-030085a82950e05d
diff --git a/htroot/yacy/crawlReceipt.java b/htroot/yacy/crawlReceipt.java
index eaf825ce0..4e3ace6f8 100644
--- a/htroot/yacy/crawlReceipt.java
+++ b/htroot/yacy/crawlReceipt.java
@@ -110,9 +110,15 @@ public final class crawlReceipt {
stale - the resource was reloaded but not processed because source had no changes
*/
-
+
final yacySeed otherPeer = yacyCore.seedDB.get(iam);
- final String otherPeerName = iam + ":" + ((otherPeer == null) ? "NULL" : (otherPeer.getName() + "/" + otherPeer.getVersion()));
+ if (otherPeer == null) {
+ prop.put("delay", "3600");
+ return prop;
+ } else {
+ otherPeer.setLastSeenUTC();
+ }
+ final String otherPeerName = iam + ":" + otherPeer.getName() + "/" + otherPeer.getVersion();
if ((yacyCore.seedDB.mySeed() == null) || (!(yacyCore.seedDB.mySeed().hash.equals(youare)))) {
// no yacy connection / unknown peers
diff --git a/htroot/yacy/query.java b/htroot/yacy/query.java
index b25d9e249..22b65c729 100644
--- a/htroot/yacy/query.java
+++ b/htroot/yacy/query.java
@@ -53,6 +53,7 @@ import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.yacy.yacyCore;
import de.anomic.yacy.yacyNetwork;
+import de.anomic.yacy.yacySeed;
public final class query {
@@ -79,12 +80,20 @@ public final class query {
// System.out.println("YACYQUERY: RECEIVED POST = " + ((post == null) ? "NULL" : post.toString()));
-// final String iam = post.get("iam", ""); // complete seed of the requesting peer
+ final String iam = post.get("iam", ""); // complete seed of the requesting peer
final String youare = post.get("youare", ""); // seed hash of the target peer, used for testing network stability
// final String key = post.get("key", ""); // transmission key for response
final String obj = post.get("object", ""); // keyword for query subject
final String env = post.get("env", ""); // argument to query
+ final yacySeed otherPeer = yacyCore.seedDB.get(iam);
+ if (otherPeer == null) {
+ prop.put("response", "0");
+ return prop;
+ } else {
+ otherPeer.setLastSeenUTC();
+ }
+
prop.put("mytime", serverDate.formatShortSecond());
// check if we are the right target and requester has correct information about this peer
diff --git a/htroot/yacy/search.java b/htroot/yacy/search.java
index 0166add75..4160a2117 100644
--- a/htroot/yacy/search.java
+++ b/htroot/yacy/search.java
@@ -71,6 +71,16 @@ public final class search {
final String oseed = post.get("myseed", ""); // complete seed of the requesting peer
// final String youare = post.get("youare", ""); // seed hash of the target peer, used for testing network stability
final String key = post.get("key", ""); // transmission key for response
+
+ final yacySeed otherPeer = yacySeed.genRemoteSeed(oseed, key, false);
+ if (otherPeer == null) {
+ prop.put("links", "");
+ prop.put("linkcount", "0");
+ prop.put("references", "");
+ return prop;
+ }
+ otherPeer.setLastSeenUTC();
+
final String query = post.get("query", ""); // a string of word hashes that shall be searched and combined
final String exclude= post.get("exclude", "");// a string of word hashes that shall not be within the search result
String urls = post.get("urls", ""); // a string of url hashes that are preselected for the search: no other may be returned
diff --git a/htroot/yacy/transfer.java b/htroot/yacy/transfer.java
index 499218c3c..7f13dbc3f 100644
--- a/htroot/yacy/transfer.java
+++ b/htroot/yacy/transfer.java
@@ -81,13 +81,14 @@ public final class transfer {
prop.put("process_path", "");
prop.put("process_maxsize", "0");
- if (sb.isRobinsonMode() || !sb.rankingOn) {
- // in a robinson environment, do not answer. We do not do any transfer in a robinson cluster.
- return prop;
+ final yacySeed otherseed = yacyCore.seedDB.get(otherpeer);
+ if (otherseed == null || sb.isRobinsonMode() || !sb.rankingOn) {
+ // in a robinson environment, do not answer. We do not do any transfer in a robinson cluster.
+ return prop;
}
+ otherseed.setLastSeenUTC();
- yacySeed otherseed = yacyCore.seedDB.get(otherpeer);
- if ((otherseed == null) || (filename.indexOf("..") >= 0)) {
+ if (filename.indexOf("..") >= 0) {
// reject unknown peers: this does not appear fair, but anonymous senders are dangerous
// reject paths that contain '..' because they are dangerous
if (otherseed == null) sb.getLog().logFine("RankingTransmission: rejected unknown peer '" + otherpeer + "', current IP " + header.get("CLIENTIP", "unknown"));
diff --git a/htroot/yacy/transferRWI.java b/htroot/yacy/transferRWI.java
index 15ba2d4a8..2e796afb9 100644
--- a/htroot/yacy/transferRWI.java
+++ b/htroot/yacy/transferRWI.java
@@ -87,9 +87,18 @@ public final class transferRWI {
boolean blockBlacklist = sb.getConfig("indexReceiveBlockBlacklist", "false").equals("true");
boolean checkLimit = sb.getConfigBool("indexDistribution.transferRWIReceiptLimitEnabled", true);
final long cachelimit = sb.getConfigLong("indexDistribution.dhtReceiptLimit", 10000);
+
final yacySeed otherPeer = yacyCore.seedDB.get(iam);
- final String otherPeerName = iam + ":" + ((otherPeer == null) ? "NULL" : (otherPeer.getName() + "/" + otherPeer.getVersion()));
-
+ if (otherPeer == null) {
+ prop.put("unknownURL", "");
+ prop.put("result", "busy");
+ prop.put("pause", "120000");
+ return prop;
+ } else {
+ otherPeer.setLastSeenUTC();
+ }
+ final String otherPeerName = iam + ":" + otherPeer.getName() + "/" + otherPeer.getVersion();
+
// response values
String result = "ok";
StringBuffer unknownURLs = new StringBuffer();
diff --git a/htroot/yacy/transferURL.java b/htroot/yacy/transferURL.java
index 6708b9e8e..07f2f25ff 100644
--- a/htroot/yacy/transferURL.java
+++ b/htroot/yacy/transferURL.java
@@ -82,13 +82,20 @@ public final class transferURL {
final boolean granted = sb.getConfig("allowReceiveIndex", "false").equals("true");
final boolean blockBlacklist = sb.getConfig("indexReceiveBlockBlacklist", "false").equals("true");
+ final yacySeed otherPeer = yacyCore.seedDB.get(iam);
+ if (otherPeer == null) {
+ prop.put("result", "error_not_granted");
+ prop.put("pause", "120000");
+ return prop;
+ } else {
+ otherPeer.setLastSeenUTC();
+ }
+ final String otherPeerName = iam + ":" + otherPeer.getName() + "/" + otherPeer.getVersion();
+
// response values
String result = "";
String doublevalues = "0";
- final yacySeed otherPeer = yacyCore.seedDB.get(iam);
- final String otherPeerName = iam + ":" + ((otherPeer == null) ? "NULL" : (otherPeer.getName() + "/" + otherPeer.getVersion()));
-
if ((youare == null) || (!youare.equals(yacyCore.seedDB.mySeed().hash))) {
sb.getLog().logInfo("Rejecting URLs from peer " + otherPeerName + ". Wrong target. Wanted peer=" + youare + ", iam=" + yacyCore.seedDB.mySeed().hash);
result = "wrong_target";