only count locally generated lookup messages for detecting local DoS (duh)
This commit is contained in:
@ -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,12 +53,15 @@ 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 });
|
||||
|
||||
// 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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return number of netDb messages in this period, if flood, else 0
|
||||
|
@ -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());
|
||||
|
@ -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);
|
||||
|
@ -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());
|
||||
|
Reference in New Issue
Block a user