diff --git a/src/freenet/node/LocationManager.java b/src/freenet/node/LocationManager.java index 03b58fc0eb7..66d4a68d957 100644 --- a/src/freenet/node/LocationManager.java +++ b/src/freenet/node/LocationManager.java @@ -278,10 +278,14 @@ private void tryToRequestPitchBlackCheckFromYesterday( try { sskFetchResult = highLevelSimpleClient.fetch(insertFromYesterday.getURI()); if (!Arrays.equals(expectedContent, sskFetchResult.asByteArray())) { + // if we received false data, this is definitely an attack: move there to provide a good node in the location switchLocationToDefendAgainstPitchBlackAttack(insertFromYesterday); } } catch (FetchException e) { - if (isRequestExceptionBecauseUriIsNotAvailable(e)) { + if (isRequestExceptionBecauseUriIsNotAvailable(e) && node.fastWeakRandom.nextBoolean()) { + // switch to the attacked location with only 50% probability, + // because it could be caused by the defensive swap of another node + // which made its current content inaccessible. switchLocationToDefendAgainstPitchBlackAttack(insertFromYesterday); } return; @@ -310,7 +314,10 @@ private void tryToRequestPitchBlackCheckFromYesterday( try { highLevelSimpleClient.fetch(calculatedChkUri); } catch (FetchException e) { - if (isRequestExceptionBecauseUriIsNotAvailable(e)) { + if (isRequestExceptionBecauseUriIsNotAvailable(e) && node.fastWeakRandom.nextBoolean()) { + // switch to the attacked location with only 50% probability, + // because it could be caused by the defensive swap of another node + // which made its current content inaccessible. try { switchLocationToDefendAgainstPitchBlackAttack(new ClientCHK(calculatedChkUri)); } catch (MalformedURLException exception) {