java.lang.Object
net.i2p.router.networkdb.kademlia.FloodThrottler
Provides basic denial-of-service protection for database flood operations.
Tracks recent flood frequency for each key to prevent excessive flooding of the same data. Implements simple rate limiting with configurable thresholds and automatic cleanup of expired counters.
Offers lightweight DOS protection by rejecting flood operations that exceed maximum frequency limits within a time window. This is a partial solution and should be used in conjunction with other security mechanisms for comprehensive protection.
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classClears the flood counts on a schedule.Field Summary
FieldsModifier and TypeFieldDescriptionprivate final FloodThrottler.CleanerTimer clearing the counts periodically.private static final longHow often the counts are cleared: 45 sec.private final ObjectCounter<Hash> Lookup floods counted per peer.private static final intMost floods from one peer before it is throttled.Constructor Summary
ConstructorsMethod Summary
All MethodsModifier and TypeMethodDescription(package private) voidcancel()Stop the periodic cleaner.(package private) booleanIncrements the counter and checks if the hash should be throttled.
Field Details
counter
Lookup floods counted per peer._cleaner
Timer clearing the counts periodically.MAX_FLOODS
private static final int MAX_FLOODSMost floods from one peer before it is throttled.- See Also:
CLEAN_TIME
private static final long CLEAN_TIMEHow often the counts are cleared: 45 sec.- See Also:
Constructor Details
FloodThrottler
FloodThrottler()Creates a new FloodThrottler.
Method Details
shouldThrottle
Increments the counter and checks if the hash should be throttled.- Parameters:
h- the hash to check- Returns:
- true if the hash should be throttled
cancel
void cancel()Stop the periodic cleaner. Call on facade shutdown.