seedDB helpers

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4447 6c8d7289-2bf4-0310-a012-ef5d649a1542
This commit is contained in:
borg-0300 2008-02-05 16:32:10 +00:00
parent ebe07b736c
commit 85a82950e0
6 changed files with 55 additions and 13 deletions

View File

@ -112,7 +112,13 @@ public final class crawlReceipt {
*/
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

View File

@ -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

View File

@ -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

View File

@ -81,13 +81,14 @@ public final class transfer {
prop.put("process_path", "");
prop.put("process_maxsize", "0");
if (sb.isRobinsonMode() || !sb.rankingOn) {
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"));

View File

@ -87,8 +87,17 @@ 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";

View File

@ -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";