mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 16:06:16 -04:00
Fix/log4js (#5766)
* Updated log4js * Updated log4js version. * Removed requests and moved to axios. * Fixed startup. * Fixed windows dependency install. * Fixed import export rate limiter. * Fixed all log levels.
This commit is contained in:
parent
f64ddd9cb1
commit
f649b1e6f7
10 changed files with 114 additions and 52 deletions
|
@ -11,13 +11,16 @@ const securityManager = require('../../db/SecurityManager');
|
|||
const webaccess = require('./webaccess');
|
||||
|
||||
exports.expressCreateServer = (hookName, args, cb) => {
|
||||
settings.importExportRateLimiting.onLimitReached = (req, res, options) => {
|
||||
// when the rate limiter triggers, write a warning in the logs
|
||||
console.warn('Import/Export rate limiter triggered on ' +
|
||||
`"${req.originalUrl}" for IP address ${req.ip}`);
|
||||
};
|
||||
// The rate limiter is created in this hook so that restarting the server resets the limiter.
|
||||
const limiter = rateLimit(settings.importExportRateLimiting);
|
||||
const limiter = rateLimit({
|
||||
...settings.importExportRateLimiting,
|
||||
handler: (request, response, next, options) => {
|
||||
if (request.rateLimit.current === request.rateLimit.limit + 1) {
|
||||
// when the rate limiter triggers, write a warning in the logs
|
||||
console.warn('Import/Export rate limiter triggered on ' +
|
||||
`"${request.originalUrl}" for IP address ${request.ip}`);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
// handle export requests
|
||||
args.app.use('/p/:pad/:rev?/export/:type', limiter);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue