net.i2p.i2ptunnel
Class ConnThrottler
java.lang.Object
net.i2p.i2ptunnel.ConnThrottler
class ConnThrottler
- extends Object
Count how often something happens with a particular peer and all peers.
This offers basic DOS protection but is not a complete solution.
This is a little different from the one in streaming, in that the
ban time is different from the check time, and we keep a separate
map of throttled peers with individual time stamps.
The streaming version is lightweight but "sloppy" since it
uses a single time bucket for all.
- Since:
- 0.9.9
Constructor Summary |
ConnThrottler(int max,
int totalMax,
long period,
long throttlePeriod,
long totalThrottlePeriod,
String action,
Log log)
|
Method Summary |
void |
clear()
start over |
boolean |
shouldThrottle(Hash h)
Checks both individual and total. |
void |
updateLimits(int max,
int totalMax,
long checkPeriod,
long throttlePeriod,
long totalThrottlePeriod)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ConnThrottler
public ConnThrottler(int max,
int totalMax,
long period,
long throttlePeriod,
long totalThrottlePeriod,
String action,
Log log)
updateLimits
public void updateLimits(int max,
int totalMax,
long checkPeriod,
long throttlePeriod,
long totalThrottlePeriod)
shouldThrottle
public boolean shouldThrottle(Hash h)
- Checks both individual and total. Increments before checking.
clear
public void clear()
- start over