java.lang.Object
net.i2p.i2ptunnel.access.DestTracker
Tracks connection attempts for a specific remote destination.
Field Summary
Constructor Summary
ConstructorsConstructorDescriptionDestTracker(Hash hash, Threshold threshold) Create a tracker for one remote destination with an empty access history.Method Summary
All MethodsModifier and TypeMethodDescription(package private) AccessCounterThe recorded access history, for callers that need to inspect it.(package private) HashgetHash()The destination this tracker counts attempts for.(package private) booleanisBreached(Threshold threshold, long now) Test the recorded attempts against a threshold, ageing out any that fall outside the rule's window.(package private) booleanpurge(long olderThan) Drop access records that have aged out of the rule's window.(package private) booleanrecordAccess(long now) Record a connection attempt at this destination and test the result.
Field Details
hash
The destination this rule tracks.threshold
The limit applied to that destination.counter
Counts the connections in the window.
Constructor Details
DestTracker
Method Details
getHash
getCounter
AccessCounter getCounter()The recorded access history, for callers that need to inspect it.- Returns:
- the access counter
isBreached
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 attemptsnow- 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