Skip to content

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

fix for http://www.yacy-forum.de/viewtopic.php?p=34962#34962

orbiterd4428947afb3
diff --git a/htroot/yacy/query.java b/htroot/yacy/query.java
index 882fd4f17..382100b7d 100644
--- a/htroot/yacy/query.java
+++ b/htroot/yacy/query.java
@@ -65,13 +65,16 @@ public final class query {
if (prop == null || sb == null) { return null; }
if ((sb.isRobinsonMode()) &&
- (!((sb.isPublicRobinson()) ||
- (sb.isInMyCluster((String)header.get(httpHeader.CONNECTION_PROP_CLIENTIP)))))) {
- // if we are a robinson cluster, answer only if this client is known by our network definition
+ (!sb.isPublicRobinson()) &&
+ (!sb.isInMyCluster((String)header.get(httpHeader.CONNECTION_PROP_CLIENTIP)))) {
+ // if we are a robinson cluster, answer only if we are public robinson peers,
+ // or we are a private cluster and the requester is in our cluster.
+ // if we don't answer, the remote peer will recognize us as junior peer,
+ // what would mean that our peer ping does not work
prop.putASIS("response", "-1"); // request rejected
return prop;
}
-
+
// System.out.println("YACYQUERY: RECEIVED POST = " + ((post == null) ? "NULL" : post.toString()));
// final String iam = post.get("iam", ""); // complete seed of the requesting peer
diff --git a/htroot/yacy/transferRWI.java b/htroot/yacy/transferRWI.java
index 6dd0057cb..ee4668867 100644
--- a/htroot/yacy/transferRWI.java
+++ b/htroot/yacy/transferRWI.java
@@ -74,7 +74,7 @@ public final class transferRWI {
// request values
final String iam = post.get("iam", ""); // seed hash of requester
-// final String youare = (String) post.get("youare", ""); // seed hash of the target peer, needed for network stability
+ final String youare = (String) post.get("youare", ""); // seed hash of the target peer, needed for network stability
// final String key = (String) post.get("key", ""); // transmission key
final int wordc = Integer.parseInt(post.get("wordc", "")); // number of different words
final int entryc = Integer.parseInt(post.get("entryc", "")); // number of entries in indexes
@@ -89,23 +89,13 @@ public final class transferRWI {
// response values
String result = "ok";
StringBuffer unknownURLs = new StringBuffer();
- int pause = 0;
+ int pause = 10000;
- /*
- boolean shortCacheFlush = false;
- if ((granted) && (sb.wordIndex.busyCacheFlush)) {
- // wait a little bit, maybe we got into a short flush slot
- for (int i = 0; i < 20; i++) {
- if (!(sb.wordIndex.busyCacheFlush)) {
- shortCacheFlush = true;
- break;
- }
- try {Thread.sleep(100);} catch (InterruptedException e) {}
- }
- }
- */
-
- if ((!granted) || (sb.isRobinsonMode())) {
+ if ((youare == null) || (!youare.equals(yacyCore.seedDB.mySeed.hash))) {
+ sb.getLog().logInfo("Rejecting RWIs from peer " + otherPeerName + ". Wrong target. Wanted peer=" + youare + ", iam=" + yacyCore.seedDB.mySeed.hash);
+ result = "wrong_target";
+ pause = 0;
+ } else if ((!granted) || (sb.isRobinsonMode())) {
// we dont want to receive indexes
sb.getLog().logInfo("Rejecting RWIs from peer " + otherPeerName + ". Not granted.");
result = "not_granted";
diff --git a/htroot/yacy/transferURL.java b/htroot/yacy/transferURL.java
index be6a966f2..a26822bcb 100644
--- a/htroot/yacy/transferURL.java
+++ b/htroot/yacy/transferURL.java
@@ -76,7 +76,7 @@ public final class transferURL {
// request values
final String iam = post.get("iam", ""); // seed hash of requester
-// final String youare = post.get("youare", ""); // seed hash of the target peer, needed for network stability
+ final String youare = post.get("youare", ""); // seed hash of the target peer, needed for network stability
// final String key = post.get("key", ""); // transmission key
final int urlc = post.getInt("urlc", 0); // number of transported urls
final boolean granted = sb.getConfig("allowReceiveIndex", "false").equals("true");
@@ -89,7 +89,10 @@ public final class transferURL {
final yacySeed otherPeer = yacyCore.seedDB.get(iam);
final String otherPeerName = iam + ":" + ((otherPeer == null) ? "NULL" : (otherPeer.getName() + "/" + otherPeer.getVersion()));
- if ((!granted) || (sb.isRobinsonMode())) {
+ 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";
+ } else if ((!granted) || (sb.isRobinsonMode())) {
sb.getLog().logInfo("Rejecting URLs from peer " + otherPeerName + ". Not granted.");
result = "error_not_granted";
} else {