Skip to content

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

- enhanced handling of own IP address inside seed - prevention of false information of own IP address - enabled searching before an own IP address is assigned (before first ping happened) - removed warning about limited search function - added better time-out settings for peer-ping process (10 seconds complete, 5 seconds for back-ping)

orbiterb21598bdd028
diff --git a/build.properties b/build.properties
index 6137aa6ea..80388327f 100644
--- a/build.properties
+++ b/build.properties
@@ -3,7 +3,7 @@ javacSource=1.5
javacTarget=1.5
# Release Configuration
-releaseVersion=0.588
+releaseVersion=0.589
stdReleaseFile=yacy_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gz
embReleaseFile=yacy_emb_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gz
proReleaseFile=yacy_pro_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gz
diff --git a/htroot/Network.java b/htroot/Network.java
index 33035f0e3..5e1783004 100644
--- a/htroot/Network.java
+++ b/htroot/Network.java
@@ -208,8 +208,8 @@ public class Network {
}
final HashMap<String, String> map = new HashMap<String, String>();
- map.put(yacySeed.IP,post.get("peerIP"));
- map.put(yacySeed.PORT,post.get("peerPort"));
+ map.put(yacySeed.IP, post.get("peerIP"));
+ map.put(yacySeed.PORT, post.get("peerPort"));
yacySeed peer = new yacySeed(post.get("peerHash"),map);
sb.updateMySeed();
@@ -384,7 +384,7 @@ public class Network {
prop.put(STR_TABLE_LIST + conCount + "_location", location);
if (complete) {
prop.put(STR_TABLE_LIST + conCount + "_complete", 1);
- prop.put(STR_TABLE_LIST + conCount + "_complete_ip", seed.get(yacySeed.IP, "-") );
+ prop.put(STR_TABLE_LIST + conCount + "_complete_ip", seed.getIP() );
prop.put(STR_TABLE_LIST + conCount + "_complete_port", seed.get(yacySeed.PORT, "-") );
prop.put(STR_TABLE_LIST + conCount + "_complete_hash", seed.hash);
prop.put(STR_TABLE_LIST + conCount + "_complete_age", seed.getAge());
diff --git a/htroot/SettingsAck_p.java b/htroot/SettingsAck_p.java
index 2b714db66..8031a9a0f 100644
--- a/htroot/SettingsAck_p.java
+++ b/htroot/SettingsAck_p.java
@@ -252,7 +252,7 @@ public class SettingsAck_p {
} else {
serverCore.useStaticIP = true;
}
- sb.webIndex.seedDB.mySeed().put(yacySeed.IP, staticIP);
+ if (yacySeed.isProperIP(staticIP) == null) sb.webIndex.seedDB.mySeed().setIP(staticIP);
env.setConfig("staticIP", staticIP);
// server access data
diff --git a/htroot/Status.html b/htroot/Status.html
index da128da09..bf901917a 100644
--- a/htroot/Status.html
+++ b/htroot/Status.html
@@ -58,7 +58,6 @@
#(urgentStatusVirgin)#::
<dt class="hintIcon"><img src="env/grafics/bad.png" width="32" height="32" alt="bad"/></dt>
<dd class="hint">You have not published your peer seed yet. This happens automatically, just wait.
- While you have this status you are not allowed to search other peers.
</dd>
#(/urgentStatusVirgin)#
diff --git a/htroot/sharedBlacklist_p.java b/htroot/sharedBlacklist_p.java
index 7a4dfc5a1..4ea9bae7a 100644
--- a/htroot/sharedBlacklist_p.java
+++ b/htroot/sharedBlacklist_p.java
@@ -107,7 +107,7 @@ public class sharedBlacklist_p {
if( sb.webIndex.seedDB != null ){ //no nullpointer error..
yacySeed seed = sb.webIndex.seedDB.getConnected(Hash);
if (seed != null) {
- String IP = seed.get(yacySeed.IP, "127.0.0.1");
+ String IP = seed.getIP();
String Port = seed.get(yacySeed.PORT, "8080");
String peerName = seed.get(yacySeed.NAME, "<" + IP + ":" + Port + ">");
prop.putHTML("page_source", peerName);
diff --git a/htroot/yacy/hello.java b/htroot/yacy/hello.java
index e5c7269b2..3bb13d927 100644
--- a/htroot/yacy/hello.java
+++ b/htroot/yacy/hello.java
@@ -112,7 +112,7 @@ public final class hello {
// we easily know the caller's IP:
final String userAgent = (String) header.get(httpHeader.USER_AGENT, "<unknown>");
- final String reportedip = remoteSeed.get(yacySeed.IP, "");
+ final String reportedip = remoteSeed.getIP();
final String reportedPeerType = remoteSeed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_JUNIOR);
final float clientversion = remoteSeed.getVersion();
@@ -133,7 +133,7 @@ public final class hello {
// try first the reportedip, since this may be a connect from a port-forwarding host
prop.put("yourip", reportedip);
- remoteSeed.put(yacySeed.IP, reportedip);
+ remoteSeed.setIP(reportedip);
urls = yacyClient.queryUrlCount(remoteSeed);
} else {
prop.put("yourip", "unknown");
@@ -152,7 +152,7 @@ public final class hello {
serverCore.checkInterruption();
prop.put("yourip", clientip);
- remoteSeed.put(yacySeed.IP, clientip);
+ remoteSeed.setIP(clientip);
urls = yacyClient.queryUrlCount(remoteSeed);
}
}
diff --git a/htroot/yacysearch.java b/htroot/yacysearch.java
index ab10dd8ad..6d9a2f549 100644
--- a/htroot/yacysearch.java
+++ b/htroot/yacysearch.java
@@ -257,8 +257,8 @@ public class yacysearch {
}
// prepare search properties
- final boolean yacyonline = ((sb.webIndex.seedDB != null) && (sb.webIndex.seedDB.mySeed() != null) && (sb.webIndex.seedDB.mySeed().getPublicAddress() != null));
- final boolean globalsearch = (global) && (yacyonline) && (sb.getConfigBool(plasmaSwitchboard.INDEX_RECEIVE_ALLOW, false));
+ //final boolean yacyonline = ((sb.webIndex.seedDB != null) && (sb.webIndex.seedDB.mySeed() != null) && (sb.webIndex.seedDB.mySeed().getPublicAddress() != null));
+ final boolean globalsearch = (global) /* && (yacyonline)*/ && (sb.getConfigBool(plasmaSwitchboard.INDEX_RECEIVE_ALLOW, false));
// do the search
TreeSet<String> queryHashes = indexWord.words2hashes(query[0]);
diff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.java
index 5c5a7e8fa..02a234b98 100644
--- a/source/de/anomic/yacy/yacyClient.java
+++ b/source/de/anomic/yacy/yacyClient.java
@@ -119,7 +119,7 @@ public final class yacyClient {
post.add(new StringPart("seed", mySeed.genSeedStr(salt)));
yacyCore.log.logFine("yacyClient.publishMySeed thread '" + Thread.currentThread().getName() + "' contacting peer at " + address);
// send request
- byte[] content = wput("http://" + address + "/yacy/hello.html", yacySeed.b64Hash2hexHash(otherHash) + ".yacyh", post);
+ byte[] content = wput("http://" + address + "/yacy/hello.html", yacySeed.b64Hash2hexHash(otherHash) + ".yacyh", post, 10000, false);
result = nxTools.table(content, "UTF-8");
break;
} catch (Exception e) {
@@ -159,9 +159,11 @@ public final class yacyClient {
// set my own seed according to new information
// we overwrite our own IP number only
if (serverCore.useStaticIP) {
- mySeed.put(yacySeed.IP, serverDomains.myPublicIP());
+ mySeed.setIP(serverDomains.myPublicIP());
} else {
- mySeed.put(yacySeed.IP, (String) result.get("yourip"));
+ String myIP = result.get("yourip");
+ String properIP = yacySeed.isProperIP(myIP);
+ if (properIP == null) mySeed.setIP(myIP);
}
// change our seed-type
@@ -220,19 +222,6 @@ public final class yacyClient {
return count;
}
- /**
- * send data to the server named by vhost
- *
- * @param address address of the server
- * @param vhost name of the server at address which should respond
- * @param post data to send (name-value-pairs)
- * @return response body
- * @throws IOException
- */
- private static byte[] wput(final String url, String vhost, final List<Part> post) throws IOException {
- return wput(url, vhost, post, 10000, false);
- }
-
/**
* send data to the server named by vhost
*
@@ -302,11 +291,11 @@ public final class yacyClient {
* @return
* @throws IOException
*/
- private static byte[] postToFile(final yacySeed target, final String filename, final List<Part> post) throws IOException {
- return wput("http://" + target.getClusterAddress() + "/yacy/" + filename, target.getHexHash() + ".yacyh", post);
+ private static byte[] postToFile(final yacySeed target, final String filename, final List<Part> post, int timeout) throws IOException {
+ return wput("http://" + target.getClusterAddress() + "/yacy/" + filename, target.getHexHash() + ".yacyh", post, timeout, false);
}
- private static byte[] postToFile(yacySeedDB seedDB, final String targetHash, final String filename, final List<Part> post) throws IOException {
- return wput("http://" + targetAddress(seedDB, targetHash) + "/yacy/" + filename, yacySeed.b64Hash2hexHash(targetHash)+ ".yacyh", post);
+ private static byte[] postToFile(yacySeedDB seedDB, final String targetHash, final String filename, final List<Part> post, int timeout) throws IOException {
+ return wput("http://" + targetAddress(seedDB, targetHash) + "/yacy/" + filename, yacySeed.b64Hash2hexHash(targetHash)+ ".yacyh", post, timeout, false);
}
public static yacySeed querySeed(yacySeed target, String seedHash) {
@@ -318,7 +307,7 @@ public final class yacyClient {
// send request
try {
- byte[] content = postToFile(target, "query.html", post);
+ byte[] content = postToFile(target, "query.html", post, 10000);
final HashMap<String, String> result = nxTools.table(content, "UTF-8");
if (result == null || result.size() == 0) { return null; }
@@ -340,7 +329,7 @@ public final class yacyClient {
// send request
try {
- byte[] content = postToFile(target, "query.html", post);
+ byte[] content = postToFile(target, "query.html", post, 5000);
final HashMap<String, String> result = nxTools.table(content, "UTF-8");
if (result == null || result.size() == 0) { return -1; }
@@ -363,7 +352,7 @@ public final class yacyClient {
// send request
try {
- byte[] content = postToFile(target, "query.html", post);
+ byte[] content = postToFile(target, "query.html", post, 5000);
final HashMap<String, String> result = nxTools.table(content, "UTF-8");
if ((result == null) || (result.size() == 0)) return -1;
@@ -675,7 +664,7 @@ public final class yacyClient {
// send request
try {
- final byte[] content = postToFile(seedDB, targetHash, "message.html", post);
+ final byte[] content = postToFile(seedDB, targetHash, "message.html", post, 5000);
final HashMap<String, String> result = nxTools.table(content, "UTF-8");
return result;
} catch (Exception e) {
@@ -702,7 +691,7 @@ public final class yacyClient {
// send request
try {
- final byte[] content = postToFile(seedDB, targetHash, "message.html", post);
+ final byte[] content = postToFile(seedDB, targetHash, "message.html", post, 20000);
final HashMap<String, String> result = nxTools.table(content, "UTF-8");
return result;
} catch (Exception e) {
@@ -740,7 +729,7 @@ public final class yacyClient {
try {
// TODO is targetAddress == url.getHost()?
final yacyURL url = new yacyURL("http://" + targetAddress + "/yacy/transfer.html", null);
- final byte[] content = wput("http://" + targetAddress + "/yacy/transfer.html", url.getHost(), post);
+ final byte[] content = wput("http://" + targetAddress + "/yacy/transfer.html", url.getHost(), post, 10000);
final HashMap<String, String> result = nxTools.table(content, "UTF-8");
return result;
} catch (Exception e) {
@@ -841,7 +830,7 @@ public final class yacyClient {
// send request
try {
- byte[] content = wput("http://" + address + "/yacy/crawlReceipt.html", target.getHexHash() + ".yacyh", post);
+ byte[] content = wput("http://" + address + "/yacy/crawlReceipt.html", target.getHexHash() + ".yacyh", post, 10000);
return nxTools.table(content, "UTF-8");
} catch (Exception e) {
// most probably a network time-out exception
@@ -1052,7 +1041,7 @@ public final class yacyClient {
String address = targetSeed.getClusterAddress();
if (address == null) { address = "localhost:8080"; }
try {
- final byte[] content = wput("http://" + address + "/yacy/profile.html", targetSeed.getHexHash() + ".yacyh", post);
+ final byte[] content = wput("http://" + address + "/yacy/profile.html", targetSeed.getHexHash() + ".yacyh", post, 5000);
return nxTools.table(content, "UTF-8");
} catch (Exception e) {
yacyCore.log.logSevere("yacyClient.getProfile error:" + e.getMessage());
diff --git a/source/de/anomic/yacy/yacyCore.java b/source/de/anomic/yacy/yacyCore.java
index c673bb639..1a887a619 100644
--- a/source/de/anomic/yacy/yacyCore.java
+++ b/source/de/anomic/yacy/yacyCore.java
@@ -172,7 +172,7 @@ public class yacyCore {
yacyCore.log.logDebug("***DEBUG publishSeedList: I can reach myself");
*/
- if ((sb.webIndex.seedDB.lastSeedUpload_myIP.equals(sb.webIndex.seedDB.mySeed().get(yacySeed.IP, "127.0.0.1"))) &&
+ if ((sb.webIndex.seedDB.lastSeedUpload_myIP.equals(sb.webIndex.seedDB.mySeed().getIP())) &&
(sb.webIndex.seedDB.lastSeedUpload_seedDBSize == sb.webIndex.seedDB.sizeConnected()) &&
(canReachMyself()) &&
(System.currentTimeMillis() - sb.webIndex.seedDB.lastSeedUpload_timeStamp < 1000 * 60 * 60 * 24) &&
@@ -514,7 +514,7 @@ public class yacyCore {
//if (ip.equals("")) ip = natLib.retrieveIP(DI604use, DI604pw);
// yacyCore.log.logDebug("DEBUG: new IP=" + ip);
- sb.webIndex.seedDB.mySeed().put(yacySeed.IP, ip);
+ if (yacySeed.isProperIP(ip) == null) sb.webIndex.seedDB.mySeed().setIP(ip);
if (sb.webIndex.seedDB.mySeed().get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_JUNIOR).equals(yacySeed.PEERTYPE_JUNIOR)) // ???????????????
sb.webIndex.seedDB.mySeed().put(yacySeed.PEERTYPE, yacySeed.PEERTYPE_SENIOR); // to start bootstraping, we need to be recognised as PEERTYPE_SENIOR peer
log.logInfo("publish: no recipient found, our address is " +
@@ -741,7 +741,7 @@ public class yacyCore {
} finally {
sb.webIndex.seedDB.lastSeedUpload_seedDBSize = sb.webIndex.seedDB.sizeConnected();
sb.webIndex.seedDB.lastSeedUpload_timeStamp = System.currentTimeMillis();
- sb.webIndex.seedDB.lastSeedUpload_myIP = sb.webIndex.seedDB.mySeed().get(yacySeed.IP, "127.0.0.1");
+ sb.webIndex.seedDB.lastSeedUpload_myIP = sb.webIndex.seedDB.mySeed().getIP();
}
}
diff --git a/source/de/anomic/yacy/yacyPeerActions.java b/source/de/anomic/yacy/yacyPeerActions.java
index d8f683cba..8c4b6a7f0 100644
--- a/source/de/anomic/yacy/yacyPeerActions.java
+++ b/source/de/anomic/yacy/yacyPeerActions.java
@@ -194,7 +194,7 @@ public class yacyPeerActions {
return true;
} else {
// the seed is new
- if ((seedDB.mySeedIsDefined()) && (seed.get(yacySeed.IP, "127.0.0.1").equals(this.seedDB.mySeed().get(yacySeed.IP, "127.0.0.1")))) {
+ if ((seedDB.mySeedIsDefined()) && (seed.getIP().equals(this.seedDB.mySeed().getIP()))) {
// seed from the same IP as the calling client: can be
// the case if there runs another one over a NAT
yacyCore.log.logFine("connect: saved NEW seed (myself IP) " + seed.getPublicAddress());
diff --git a/source/de/anomic/yacy/yacySearch.java b/source/de/anomic/yacy/yacySearch.java
index abd0f7f5a..aafb6aafb 100644
--- a/source/de/anomic/yacy/yacySearch.java
+++ b/source/de/anomic/yacy/yacySearch.java
@@ -262,7 +262,7 @@ public class yacySearch extends Thread {
kelondroBitfield constraint,
TreeMap<String, String> clusterselection) {
// check own peer status
- if (wordIndex.seedDB.mySeed() == null || wordIndex.seedDB.mySeed().getPublicAddress() == null) { return null; }
+ //if (wordIndex.seedDB.mySeed() == null || wordIndex.seedDB.mySeed().getPublicAddress() == null) { return null; }
// prepare seed targets and threads
final yacySeed[] targetPeers = (clusterselection == null) ? selectSearchTargets(wordIndex.seedDB, wordIndex.peerActions, plasmaSearchQuery.hashes2Set(wordhashes), targets) : selectClusterPeers(wordIndex.seedDB, clusterselection);
diff --git a/source/de/anomic/yacy/yacySeed.java b/source/de/anomic/yacy/yacySeed.java
index c3ba47f9b..fae10b86f 100644
--- a/source/de/anomic/yacy/yacySeed.java
+++ b/source/de/anomic/yacy/yacySeed.java
@@ -357,7 +357,6 @@ public class yacySeed {
} else return dflt;
}
- public final void setIP() { dna.put(yacySeed.IP, ""); }
public final void setIP(String ip) { dna.put(yacySeed.IP, ip); }
public final void setPort(String port) { dna.put(yacySeed.PORT, port); }
public final void setType(String type) { dna.put(yacySeed.PEERTYPE, type); }
@@ -858,11 +857,8 @@ public class yacySeed {
// check IP
if (!checkOwnIP) {
// checking of IP is omitted if we read the own seed file
- final String ip = (String) this.dna.get(yacySeed.IP);
- if (ip == null) return "IP is null";
- if (ip.length() > 0 && ip.length() < 8) return "IP is too short: " + ip;
- if (!natLib.isProper(ip)) return "IP is not proper: " + ip; //this does not work with staticIP
- if (ip.equals("localhost") || ip.startsWith("127.") || (ip.startsWith("0:0:0:0:0:0:0:1"))) return "IP for localhost rejected";
+ final String ipCheck = isProperIP(this.dna.get(yacySeed.IP));
+ if (ipCheck != null) return ipCheck;
}
// seedURL
@@ -880,6 +876,15 @@ public class yacySeed {
return null;
}
+ public static final String isProperIP(String ipString) {
+ // returns null if ipString is proper, a string with the cause otervise
+ if (ipString == null) return "IP is null";
+ if (ipString.length() > 0 && ipString.length() < 8) return "IP is too short: " + ipString;
+ if (!natLib.isProper(ipString)) return "IP is not proper: " + ipString; //this does not work with staticIP
+ if (ipString.equals("localhost") || ipString.startsWith("127.") || (ipString.startsWith("0:0:0:0:0:0:0:1"))) return "IP for localhost rejected";
+ return null;
+ }
+
public final String toString() {
synchronized (this.dna) {
this.dna.put(yacySeed.HASH, this.hash); // set hash into seed code structure
diff --git a/source/de/anomic/yacy/yacySeedDB.java b/source/de/anomic/yacy/yacySeedDB.java
index 91d9d8d0a..bc6011397 100644
--- a/source/de/anomic/yacy/yacySeedDB.java
+++ b/source/de/anomic/yacy/yacySeedDB.java
@@ -179,7 +179,7 @@ public final class yacySeedDB implements httpdAlternativeDomainNames {
}
}
- mySeed.put(yacySeed.IP, ""); // we delete the old information to see what we have now
+ mySeed.setIP(""); // we delete the old information to see what we have now
mySeed.put(yacySeed.PEERTYPE, yacySeed.PEERTYPE_VIRGIN); // markup startup condition
}