This commit is contained in:
zzz
2011-12-04 18:53:24 +00:00
parent cc71e3a5ca
commit 69cae1a052
2 changed files with 4 additions and 6 deletions

View File

@@ -27,13 +27,13 @@ class RouterDoSThrottle extends RouterThrottleImpl {
if (!shouldAccept) return false; if (!shouldAccept) return false;
// now lets check for DoS // now lets check for DoS
long now = getContext().clock().now(); long now = _context.clock().now();
if (_currentLookupPeriod + LOOKUP_THROTTLE_PERIOD > now) { if (_currentLookupPeriod + LOOKUP_THROTTLE_PERIOD > now) {
// same period, check for DoS // same period, check for DoS
_currentLookupCount++; _currentLookupCount++;
if (_currentLookupCount >= LOOKUP_THROTTLE_MAX) { if (_currentLookupCount >= LOOKUP_THROTTLE_MAX) {
getContext().statManager().addRateData("router.throttleNetDbDoS", _currentLookupCount, 0); _context.statManager().addRateData("router.throttleNetDbDoS", _currentLookupCount, 0);
int rand = getContext().random().nextInt(_currentLookupCount); int rand = _context.random().nextInt(_currentLookupCount);
if (rand > LOOKUP_THROTTLE_MAX) { if (rand > LOOKUP_THROTTLE_MAX) {
return false; return false;
} else { } else {

View File

@@ -14,7 +14,7 @@ import net.i2p.util.SimpleTimer;
* *
*/ */
class RouterThrottleImpl implements RouterThrottle { class RouterThrottleImpl implements RouterThrottle {
private final RouterContext _context; protected final RouterContext _context;
private final Log _log; private final Log _log;
private String _tunnelStatus; private String _tunnelStatus;
@@ -538,8 +538,6 @@ class RouterThrottleImpl implements RouterThrottle {
_tunnelStatus = msg; _tunnelStatus = msg;
} }
protected RouterContext getContext() { return _context; }
/** /**
* Mark a string for extraction by xgettext and translation. * Mark a string for extraction by xgettext and translation.
* Use this only in static initializers. * Use this only in static initializers.