forked from I2P_Developers/i2p.i2p
I2PTunnel: Start/stop POST throttle timer
This commit is contained in:
@ -39,8 +39,12 @@ class ConnThrottler {
|
||||
private final String _action;
|
||||
private final Log _log;
|
||||
private final DateFormat _fmt;
|
||||
private final SimpleTimer2.TimedEvent _cleaner;
|
||||
private boolean _isRunning;
|
||||
|
||||
/*
|
||||
* Caller MUST call start()
|
||||
*
|
||||
* @param max per-peer, 0 for unlimited
|
||||
* @param totalMax for all peers, 0 for unlimited
|
||||
* @param period check window (ms)
|
||||
@ -57,7 +61,30 @@ class ConnThrottler {
|
||||
// for logging
|
||||
_fmt = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM);
|
||||
_fmt.setTimeZone(SystemVersion.getSystemTimeZone());
|
||||
new Cleaner();
|
||||
_cleaner = new Cleaner();
|
||||
}
|
||||
|
||||
/*
|
||||
* If already started, has no effect.
|
||||
*
|
||||
* @since 0.9.40
|
||||
*/
|
||||
public synchronized void start() {
|
||||
if (_isRunning)
|
||||
return;
|
||||
_isRunning = true;
|
||||
_cleaner.schedule(_checkPeriod);
|
||||
}
|
||||
|
||||
/*
|
||||
* May be restarted.
|
||||
*
|
||||
* @since 0.9.40
|
||||
*/
|
||||
public synchronized void stop() {
|
||||
_isRunning = false;
|
||||
_cleaner.cancel();
|
||||
clear();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -176,9 +203,9 @@ class ConnThrottler {
|
||||
}
|
||||
|
||||
private class Cleaner extends SimpleTimer2.TimedEvent {
|
||||
/** schedules itself */
|
||||
/** must call schedule() later */
|
||||
public Cleaner() {
|
||||
super(SimpleTimer2.getInstance(), _checkPeriod);
|
||||
super(SimpleTimer2.getInstance());
|
||||
}
|
||||
|
||||
public void timeReached() {
|
||||
|
@ -233,6 +233,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
||||
_postThrottler = new ConnThrottler(pp, pt, pw, pb, px, "POST/PUT", _log);
|
||||
else
|
||||
_postThrottler.updateLimits(pp, pt, pw, pb, px);
|
||||
_postThrottler.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -254,7 +255,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
||||
public boolean close(boolean forced) {
|
||||
synchronized(this) {
|
||||
if (_postThrottler != null)
|
||||
_postThrottler.clear();
|
||||
_postThrottler.stop();
|
||||
}
|
||||
return super.close(forced);
|
||||
}
|
||||
|
12
history.txt
12
history.txt
@ -1,5 +1,15 @@
|
||||
2019-04-03 zzz
|
||||
* I2PTunnel: Start/stop POST throttle timer
|
||||
|
||||
2019-04-02 zab
|
||||
* I2PTunnel: mplement access filtering (ticket #2464
|
||||
* I2PTunnel: Implement access filtering (ticket #2464)
|
||||
|
||||
2019-03-31 zzz
|
||||
* Data: Implement Destroyable for private keys (ticket #2462)
|
||||
|
||||
2019-03-29 zzz
|
||||
* Crypto: SigContext (WIP) (proposal #148)
|
||||
* NetDB: Persist cached blinding data (proposal #123)
|
||||
|
||||
2019-03-27 zzz
|
||||
* NetDB: Cache blinding data for lookups and decryption (proposal #123)
|
||||
|
Reference in New Issue
Block a user