java.lang.Object
net.i2p.router.networkdb.kademlia.FloodThrottler

class FloodThrottlerextends Object
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.

  • Field Details

    • counter

      private final ObjectCounter<Hash> counter
      Lookup floods counted per peer.
    • _cleaner

      private final FloodThrottler.Cleaner _cleaner
      Timer clearing the counts periodically.
    • MAX_FLOODS

      private static final int MAX_FLOODS
      Most floods from one peer before it is throttled.
      See Also:
    • CLEAN_TIME

      private static final long CLEAN_TIME
      How often the counts are cleared: 45 sec.
      See Also:
  • Constructor Details

    • FloodThrottler

      FloodThrottler()
      Creates a new FloodThrottler.
  • Method Details

    • shouldThrottle

      boolean shouldThrottle(Hash h)
      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.