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 //TODO: This is not IPv6 compatible
public static boolean isProper(String ip) { public static boolean isProper(String ip) {
plasmaSwitchboard sb=plasmaSwitchboard.getSwitchboard(); plasmaSwitchboard sb=plasmaSwitchboard.getSwitchboard();
if (sb == null) return false; if (sb != null) {
String yacyDebugMode = sb.getConfig("yacyDebugMode", "false"); String yacyDebugMode = sb.getConfig("yacyDebugMode", "false");
if(yacyDebugMode.equals("true")){ if (yacyDebugMode.equals("true")) {
return true; return true;
} }
//support for staticIP // support for staticIP
if(sb.getConfig("staticIP", "").equals(ip)){ if (sb.getConfig("staticIP", "").equals(ip)) {
return true; return true;
} }
if (ip == null) return false; }
if (ip.indexOf(":") >= 0) return false; // ipv6... if (ip == null) return false;
return ( isNotLocal(ip)) && (isIP(ip) ); if (ip.indexOf(":") >= 0) return false; // ipv6...
return (isNotLocal(ip)) && (isIP(ip));
} }
private static int retrieveOptions() { private static int retrieveOptions() {

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

@ -605,7 +605,9 @@ public class yacySeed {
if (seed == null) { return null; } if (seed == null) { return null; }
final HashMap dna = serverCodings.string2map(seed); final HashMap dna = serverCodings.string2map(seed);
final String hash = (String) dna.remove("Hash"); 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() { public String toString() {

Loading…
Cancel
Save