mirror of
https://github.com/yacy/yacy_search_server.git
synced 2024-09-19 00:01:41 +02:00
- 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) git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4883 6c8d7289-2bf4-0310-a012-ef5d649a1542
This commit is contained in:
parent
40d7f485f3
commit
b21598bdd0
|
@ -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
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)#
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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]);
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user