better logging for WRONG seed

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@463 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 20 years ago
parent 41be998391
commit e24dbde217

@ -143,7 +143,7 @@ public class hello {
remoteSeed.put("PeerType", "junior");
yacyCore.log.logInfo("hello: responded remote junior peer '" + remoteSeed.getName() + "' from " + reportedip);
// no connection here, instead store junior in connection cache
if ((remoteSeed.hash != null) && (remoteSeed.isProper())) yacyCore.peerActions.peerPing(remoteSeed);
if ((remoteSeed.hash != null) && (remoteSeed.isProper() == null)) yacyCore.peerActions.peerPing(remoteSeed);
}
if (!((String)prop.get("yourtype")).equals(reportedPeerType)) {
yacyCore.log.logInfo("hello: changing remote peer '" + remoteSeed.getName() + "' [" + reportedip + "] peerType from '" + reportedPeerType + "' to '" + prop.get("yourtype") + "'.");
@ -161,7 +161,7 @@ public class hello {
yacySeed[] ys = yacyCore.seedDB.seedsByAge(true, count); // latest seeds
int c = 1;
for (int i = 1; i < ys.length; i++) {
if ((ys[i] != null) && (ys[i].isProper())) {
if ((ys[i] != null) && (ys[i].isProper() == null)) {
seeds += "seed" + c + "=" + ys[i].genSeedStr(key) + serverCore.crlfString;
c++;
}

@ -189,9 +189,10 @@ public class yacyClient {
yacyCore.seedDB.mySeed.put(yacySeed.PEERTYPE, mytype);
}
if (!(yacyCore.seedDB.mySeed.isProper())) {
String error;
if ((error = yacyCore.seedDB.mySeed.isProper()) != null) {
yacyCore.seedDB.mySeed = mySeedBkp;
yacyCore.log.logDebug("yacyClient.publishMySeed mySeed error: not proper");
yacyCore.log.logDebug("yacyClient.publishMySeed mySeed error - not proper: " + error);
return -1;
}

@ -409,7 +409,7 @@ public class yacyCore {
String address = seeds[i].getAddress();
log.logDebug("HELLO #" + i + " to peer '" + seeds[i].get("Name", "") + "' at " + address); // debug
if ((address == null) || (!(seeds[i].isProper()))) {
if ((address == null) || (seeds[i].isProper() != null)) {
// we don't like that address, delete it
peerActions.peerDeparture(seeds[i]);
sync.V();
@ -471,7 +471,7 @@ public class yacyCore {
// }
// if we have an address, we do nothing
if ((seedDB.mySeed.isProper()) && (!(force))) return 0;
if ((seedDB.mySeed.isProper() == null) && (!(force))) return 0;
// still no success: ask own NAT or internet responder
boolean DI604use = switchboard.getConfig("DI604use", "false").equals("true");

@ -169,7 +169,7 @@ public class yacyPeerActions {
lc = 0;
while (enu.hasMoreElements()) {
ys = yacySeed.genRemoteSeed((String) enu.nextElement(), null, new Date());
if ((ys != null) && (ys.isProper()) &&
if ((ys != null) && (ys.isProper() == null) &&
((seedDB.mySeed == null) || (seedDB.mySeed.hash != ys.hash))) {
if (connectPeer(ys, false)) lc++;
//seedDB.writeMap(ys.hash, ys.getMap(), "init");
@ -239,11 +239,12 @@ public class yacyPeerActions {
synchronized public boolean connectPeer(yacySeed seed, boolean direct) {
// store a remote peer's seed
// returns true if the peer is new and previously unknown
if (seed == null) {
yacyCore.log.logInfo("connect: WRONG seed (NULL)");
String error;
if (seed == null) {
yacyCore.log.logError("connect: WRONG seed (NULL)");
return false;
} else if (!(seed.isProper())) {
yacyCore.log.logInfo("connect: WRONG seed (" + seed.getName() + "/" + seed.hash + ")");
} else if ((error = seed.isProper()) != null) {
yacyCore.log.logError("connect: WRONG seed (" + seed.getName() + "/" + seed.hash + "): " + error);
return false;
} else if ((seedDB.mySeed != null) && (seed.hash.equals(seedDB.mySeed.hash))) {
yacyCore.log.logInfo("connect: SELF reference " + seed.getAddress());

@ -381,13 +381,15 @@ public class yacySeed {
return crypt.simpleEncode(toString(), key, method);
}
public boolean isProper() {
public String isProper() {
// checks if everything is ok with that seed
if (this.hash == null) return false;
if (this.hash.length() != yacySeedDB.commonHashLength) return false;
if (this.hash == null) return "hash is null";
if (this.hash.length() != yacySeedDB.commonHashLength) return "wrong hash length (" + this.hash.length() + ")";
String ip = (String) dna.get("IP");
if ((ip == null) || (ip.length() < 8)) return false;
return (natLib.isProper(ip));
if (ip == null) return "IP is null";
if (ip.length() < 8) return "IP is too short: " + ip;
if (!(natLib.isProper(ip))) return "IP is not proper: " + ip;
return null;
}
public void save(File f) throws IOException {

@ -342,7 +342,7 @@ public class yacySeedDB {
public long countPotentialRWI() { return seedPotentialDB.getAcc("ICount"); }
public synchronized void addConnected(yacySeed seed) {
if ((seed == null) || (!(seed.isProper()))) return;
if ((seed == null) || (seed.isProper() != null)) return;
//seed.put("LastSeen", yacyCore.shortFormatter.format(new Date(yacyCore.universalTime())));
try {
nameLookupCache.put(seed.getName(), seed);
@ -396,7 +396,7 @@ public class yacySeedDB {
seedActiveDB.remove(seed.hash);
seedPassiveDB.remove(seed.hash);
} catch (Exception e) {}
if (!(seed.isProper())) return;
if (seed.isProper() != null) return;
//seed.put("LastSeen", yacyCore.shortFormatter.format(new Date(yacyCore.universalTime())));
try {
seedPotentialDB.set(seed.hash, seed.getMap());
@ -476,13 +476,13 @@ public class yacySeedDB {
seed = (yacySeed) e.nextElement();
if (seed != null) {
name = seed.getName().toLowerCase();
if (seed.isProper()) nameLookupCache.put(name, seed);
if (seed.isProper() == null) nameLookupCache.put(name, seed);
if (name.equals(peerName)) return seed;
}
}
// check local seed
name = mySeed.getName().toLowerCase();
if (mySeed.isProper()) nameLookupCache.put(name, mySeed);
if (mySeed.isProper() == null) nameLookupCache.put(name, mySeed);
if (name.equals(peerName)) return mySeed;
// nothing found
return null;

Loading…
Cancel
Save