only count locally generated lookup messages for detecting local DoS (duh)

This commit is contained in:
jrandom
2004-08-13 02:52:17 +00:00
committed by zzz
parent 5122f9989c
commit 3c9b0273d4
4 changed files with 15 additions and 9 deletions

View File

@ -43,6 +43,9 @@ public class DatabaseLookupMessage extends I2NPMessageImpl {
private static final long LOOKUP_THROTTLE_MAX = 50;
public DatabaseLookupMessage(I2PAppContext context) {
this(context, false);
}
public DatabaseLookupMessage(I2PAppContext context, boolean locallyCreated) {
super(context);
setSearchKey(null);
setFrom(null);
@ -50,10 +53,13 @@ public class DatabaseLookupMessage extends I2NPMessageImpl {
context.statManager().createRateStat("router.throttleNetDbDoSSend", "How many netDb lookup messages we are sending during a period with a DoS detected", "Throttle", new long[] { 60*1000, 10*60*1000, 60*60*1000, 24*60*60*1000 });
// we do this in the writeMessage so we know that we have all the data
int dosCount = detectDoS(context);
if (dosCount > 0) {
_log.log(Log.CRIT, "Are we flooding the network with NetDb messages? (" + dosCount + " messages so far)", new Exception("Flood cause"));
// only check DoS generation if we are creating the message...
if (locallyCreated) {
// we do this in the writeMessage so we know that we have all the data
int dosCount = detectDoS(context);
if (dosCount > 0) {
_log.log(Log.CRIT, "Are we flooding the network with NetDb messages? (" + dosCount + " messages so far)", new Exception("Flood cause"));
}
}
}

View File

@ -68,7 +68,7 @@ class ExploreJob extends SearchJob {
* @param expiration when the search should stop
*/
protected DatabaseLookupMessage buildMessage(TunnelId replyTunnelId, RouterInfo replyGateway, long expiration) {
DatabaseLookupMessage msg = new DatabaseLookupMessage(getContext());
DatabaseLookupMessage msg = new DatabaseLookupMessage(getContext(), true);
msg.setSearchKey(getState().getTarget());
msg.setFrom(replyGateway.getIdentity().getHash());
msg.setDontIncludePeers(getState().getAttempted());

View File

@ -108,7 +108,7 @@ class HarvesterJob extends JobImpl {
*/
private void harvest(Hash peer) {
long now = getContext().clock().now();
DatabaseLookupMessage msg = new DatabaseLookupMessage(getContext());
DatabaseLookupMessage msg = new DatabaseLookupMessage(getContext(), true);
msg.setFrom(getContext().routerHash());
msg.setMessageExpiration(new Date(10*1000+now));
msg.setSearchKey(peer);

View File

@ -355,7 +355,7 @@ class SearchJob extends JobImpl {
* @param expiration when the search should stop
*/
protected DatabaseLookupMessage buildMessage(TunnelId replyTunnelId, RouterInfo replyGateway, long expiration) {
DatabaseLookupMessage msg = new DatabaseLookupMessage(getContext());
DatabaseLookupMessage msg = new DatabaseLookupMessage(getContext(), true);
msg.setSearchKey(_state.getTarget());
msg.setFrom(replyGateway.getIdentity().getHash());
msg.setDontIncludePeers(_state.getAttempted());
@ -370,7 +370,7 @@ class SearchJob extends JobImpl {
*
*/
protected DatabaseLookupMessage buildMessage(long expiration) {
DatabaseLookupMessage msg = new DatabaseLookupMessage(getContext());
DatabaseLookupMessage msg = new DatabaseLookupMessage(getContext(), true);
msg.setSearchKey(_state.getTarget());
msg.setFrom(getContext().routerHash());
msg.setDontIncludePeers(_state.getAttempted());