Author: borg-0300
Date: 2008-02-05 17:32:10 +0100 (Tue, 05 Feb 2008)
New Revision: 4447

Modified:
   trunk/htroot/yacy/crawlReceipt.java
   trunk/htroot/yacy/query.java
   trunk/htroot/yacy/search.java
   trunk/htroot/yacy/transfer.java
   trunk/htroot/yacy/transferRWI.java
   trunk/htroot/yacy/transferURL.java
Log:
seedDB helpers

Modified: trunk/htroot/yacy/crawlReceipt.java
===================================================================
--- trunk/htroot/yacy/crawlReceipt.java 2008-02-04 23:32:19 UTC (rev 4446)
+++ trunk/htroot/yacy/crawlReceipt.java 2008-02-05 16:32:10 UTC (rev 4447)
@@ -110,9 +110,15 @@
            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

Modified: trunk/htroot/yacy/query.java
===================================================================
--- trunk/htroot/yacy/query.java        2008-02-04 23:32:19 UTC (rev 4446)
+++ trunk/htroot/yacy/query.java        2008-02-05 16:32:10 UTC (rev 4447)
@@ -53,6 +53,7 @@
 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 @@
                   
 //      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

Modified: trunk/htroot/yacy/search.java
===================================================================
--- trunk/htroot/yacy/search.java       2008-02-04 23:32:19 UTC (rev 4446)
+++ trunk/htroot/yacy/search.java       2008-02-05 16:32:10 UTC (rev 4447)
@@ -71,6 +71,16 @@
         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

Modified: trunk/htroot/yacy/transfer.java
===================================================================
--- trunk/htroot/yacy/transfer.java     2008-02-04 23:32:19 UTC (rev 4446)
+++ trunk/htroot/yacy/transfer.java     2008-02-05 16:32:10 UTC (rev 4447)
@@ -81,13 +81,14 @@
         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"));

Modified: trunk/htroot/yacy/transferRWI.java
===================================================================
--- trunk/htroot/yacy/transferRWI.java  2008-02-04 23:32:19 UTC (rev 4446)
+++ trunk/htroot/yacy/transferRWI.java  2008-02-05 16:32:10 UTC (rev 4447)
@@ -87,9 +87,18 @@
         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();

Modified: trunk/htroot/yacy/transferURL.java
===================================================================
--- trunk/htroot/yacy/transferURL.java  2008-02-04 23:32:19 UTC (rev 4446)
+++ trunk/htroot/yacy/transferURL.java  2008-02-05 16:32:10 UTC (rev 4447)
@@ -82,13 +82,20 @@
         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";

_______________________________________________
YaCy-svn mailing list
YaCy-svn@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/yacy-svn

Antwort per Email an