java.lang.Object
net.i2p.i2ptunnel.access.DestTracker

class DestTrackerextends Object
Tracks connection attempts for a specific remote destination.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final AccessCounter
    Counts the connections in the window.
    private final Hash
    The destination this rule tracks.
    private final Threshold
    The limit applied to that destination.
  • Constructor Summary

    Constructors
    Constructor
    Description
    DestTracker(Hash hash, Threshold threshold)
    Create a tracker for one remote destination with an empty access history.
  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    (package private) AccessCounter
    The recorded access history, for callers that need to inspect it.
    (package private) Hash
    The destination this tracker counts attempts for.
    (package private) boolean
    isBreached(Threshold threshold, long now)
    Test the recorded attempts against a threshold, ageing out any that fall outside the rule's window.
    (package private) boolean
    purge(long olderThan)
    Drop access records that have aged out of the rule's window.
    (package private) boolean
    recordAccess(long now)
    Record a connection attempt at this destination and test the result.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • hash

      private final Hash hash
      The destination this rule tracks.
    • threshold

      private final Threshold threshold
      The limit applied to that destination.
    • counter

      private final AccessCounter counter
      Counts the connections in the window.
  • Constructor Details

    • DestTracker

      DestTracker(Hash hash, Threshold threshold)
      Create a tracker for one remote destination with an empty access history.
      Parameters:
      hash - hash of the remote destination
      threshold - threshold defined in the access rule
  • Method Details

    • getHash

      Hash getHash()
      The destination this tracker counts attempts for.
      Returns:
      the destination hash
    • getCounter

      AccessCounter getCounter()
      The recorded access history, for callers that need to inspect it.
      Returns:
      the access counter
    • isBreached

      boolean isBreached(Threshold threshold, long now)
      Test the recorded attempts against a threshold, ageing out any that fall outside the rule's window.
      Parameters:
      threshold - the rule threshold tested against the recorded attempts
      now - current time, used to age out attempts outside the window
      Returns:
      true if the counter has breached the given threshold
    • recordAccess

      boolean recordAccess(long now)
      Record a connection attempt at this destination and test the result.
      Parameters:
      now - the time of the connection attempt being recorded
      Returns:
      true if this access causes threshold breach
    • purge

      boolean purge(long olderThan)
      Drop access records that have aged out of the rule's window.
      Parameters:
      olderThan - purge entries older than this timestamp
      Returns:
      true if nothing is left in the access history