added checks to protect peers from wrong seeds

see also: http://www.yacy-forum.de/viewtopic.php?p=19249#19249

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1939 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 19 years ago
parent eba22e7f89
commit 59fc55ea1e

@ -125,19 +125,20 @@ public class natLib {
//TODO: This is not IPv6 compatible
public static boolean isProper(String ip) {
plasmaSwitchboard sb=plasmaSwitchboard.getSwitchboard();
if (sb == null) return false;
String yacyDebugMode = sb.getConfig("yacyDebugMode", "false");
if(yacyDebugMode.equals("true")){
return true;
}
//support for staticIP
if(sb.getConfig("staticIP", "").equals(ip)){
return true;
}
if (ip == null) return false;
if (ip.indexOf(":") >= 0) return false; // ipv6...
return ( isNotLocal(ip)) && (isIP(ip) );
plasmaSwitchboard sb=plasmaSwitchboard.getSwitchboard();
if (sb != null) {
String yacyDebugMode = sb.getConfig("yacyDebugMode", "false");
if (yacyDebugMode.equals("true")) {
return true;
}
// support for staticIP
if (sb.getConfig("staticIP", "").equals(ip)) {
return true;
}
}
if (ip == null) return false;
if (ip.indexOf(":") >= 0) return false; // ipv6...
return (isNotLocal(ip)) && (isIP(ip));
}
private static int retrieveOptions() {

@ -400,6 +400,7 @@ public class yacyPeerActions {
}
public boolean peerArrival(yacySeed peer, boolean direct) {
if (peer == null) return false;
boolean res = connectPeer(peer, direct);
// perform all actions if peer is effective new
if (res) {
@ -410,6 +411,7 @@ public class yacyPeerActions {
}
public void peerDeparture(yacySeed peer) {
if (peer == null) return;
//System.out.println("PEER DEPARTURE:" + peer.toString());
disconnectPeer(peer);
// perform all actions
@ -418,6 +420,7 @@ public class yacyPeerActions {
}
public void peerPing(yacySeed peer) {
if (peer == null) return;
// this is called only if the peer has junior status
seedDB.addPotential(peer);
// perform all actions

@ -605,7 +605,9 @@ public class yacySeed {
if (seed == null) { return null; }
final HashMap dna = serverCodings.string2map(seed);
final String hash = (String) dna.remove("Hash");
return new yacySeed(hash, dna);
yacySeed resultSeed = new yacySeed(hash, dna);
if (resultSeed.isProper() == null) return resultSeed;
return null;
}
public String toString() {

Loading…
Cancel
Save