Add some sanity checks for invalid seeds

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5042 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
hermens 17 years ago
parent cff4393f0c
commit 3ac1988059

@ -273,6 +273,12 @@ public class yacyCore {
// check if seed's lastSeen has been updated
final yacySeed newSeed = sb.webIndex.seedDB.getConnected(this.seed.hash);
if (newSeed != null) {
if (!newSeed.isOnline()) {
log.logFine("publish: recently handshaked " + this.seed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_SENIOR) +
" peer '" + this.seed.getName() + "' at " + this.seed.getPublicAddress() + " is not online." +
" Removing Peer from connected");
sb.webIndex.peerActions.peerDeparture(newSeed, "peer not online");
} else
if (newSeed.getLastSeenUTC() < (System.currentTimeMillis() - 10000)) {
// update last seed date
if (newSeed.getLastSeenUTC() >= this.seed.getLastSeenUTC()) {

@ -80,6 +80,11 @@ public class yacyPeerActions {
yacyCore.log.logFine("connect: rejecting NOT QUALIFIED " + peerType + " seed " + seed.getName());
return false;
}
if (!(peerType.equals(yacySeed.PEERTYPE_SENIOR) || peerType.equals(yacySeed.PEERTYPE_PRINCIPAL))) {
// reject unqualified seeds
yacyCore.log.logFine("connect: rejecting NOT QUALIFIED " + peerType + " seed " + seed.getName());
return false;
}
final yacySeed doubleSeed = this.seedDB.lookupByIP(seed.getInetAddress(), true, false, false);
if ((doubleSeed != null) && (doubleSeed.getPort() == seed.getPort()) && (!(doubleSeed.hash.equals(seed.hash)))) {

@ -535,10 +535,10 @@ public class yacySeed implements Cloneable {
// of the local UTC offset is wrong. We correct this here by adding the local UTC
// offset again.
return t + serverDate.UTCDiff();
} catch (final java.text.ParseException e) {
return System.currentTimeMillis();
} catch (final java.text.ParseException e) { // in case of an error make seed look old!!!
return System.currentTimeMillis() - serverDate.dayMillis;
} catch (final java.lang.NumberFormatException e) {
return System.currentTimeMillis();
return System.currentTimeMillis() - serverDate.dayMillis;
}
}
@ -835,7 +835,14 @@ public class yacySeed implements Cloneable {
final String peerName = this.dna.get(yacySeed.NAME);
if (peerName == null) return "no peer name given";
dna.put(yacySeed.NAME, checkPeerName(peerName));
// type
final String peerType = this.getPeerType();
if ((peerType == null) ||
!(peerType.equals(yacySeed.PEERTYPE_VIRGIN) || peerType.equals(yacySeed.PEERTYPE_JUNIOR)
|| peerType.equals(yacySeed.PEERTYPE_SENIOR) || peerType.equals(yacySeed.PEERTYPE_PRINCIPAL)))
return "invalid peerType '" + peerType + "'";
// check IP
if (!checkOwnIP) {
// checking of IP is omitted if we read the own seed file

Loading…
Cancel
Save