mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 23:46:14 -04:00
Defer rate limiter creation to a hook call
This makes it possible to change the rate limiter settings via `/admin/settings` or by modifying the appropriate settings object and reinvoking the hook.
This commit is contained in:
parent
d7ed71eba0
commit
00d45e3229
3 changed files with 18 additions and 13 deletions
|
@ -40,10 +40,14 @@ const nodeify = require('nodeify');
|
|||
const {RateLimiterMemory} = require('rate-limiter-flexible');
|
||||
const webaccess = require('../hooks/express/webaccess');
|
||||
|
||||
const rateLimiter = new RateLimiterMemory({
|
||||
points: settings.commitRateLimiting.points,
|
||||
duration: settings.commitRateLimiting.duration,
|
||||
});
|
||||
let rateLimiter;
|
||||
|
||||
exports.socketio = () => {
|
||||
// The rate limiter is created in this hook so that restarting the server resets the limiter. The
|
||||
// settings.commitRateLimiting object is passed directly to the rate limiter so that the limits
|
||||
// can be dynamically changed during runtime by modifying its properties.
|
||||
rateLimiter = new RateLimiterMemory(settings.commitRateLimiting);
|
||||
};
|
||||
|
||||
/**
|
||||
* A associative array that saves information about a session
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue