Updated backend
- Added better anti DoS protection - Added better security measures (HTTP headers, etc.) - Added TLS support - Added support for configurable rate limiting - Added default 404 and error handling - Updated proxy settings - Updated env naming
This commit is contained in:
@@ -6,7 +6,7 @@ import { log } from './logManager';
|
||||
|
||||
const requestLimiter = rateLimit({
|
||||
windowMs: 60 * 1000,
|
||||
max: 5,
|
||||
max: process.env.RATE_LIMIT_REQUESTS || 100,
|
||||
standardHeaders: true,
|
||||
legacyHeaders: false,
|
||||
message: 'Too many requests from this IP, please try again later',
|
||||
@@ -18,6 +18,22 @@ const speedLimiter = slowDown({
|
||||
delayMs: (hits) => hits * 100,
|
||||
});
|
||||
|
||||
const antiBruteForce = rateLimit({
|
||||
windowMs: 60 * 60 * 1000,
|
||||
max: process.env.RATE_LIMIT_LOGIN_ATTEMPTS || 5,
|
||||
standardHeaders: true,
|
||||
legacyHeaders: false,
|
||||
message: 'Too many login attempts, please try again later',
|
||||
});
|
||||
|
||||
const antiVerificationSpam = rateLimit({
|
||||
windowMs: 60 * 1000,
|
||||
max: process.env.RATE_LIMIT_VERIFICATION_REQUESTS || 5,
|
||||
standardHeaders: true,
|
||||
legacyHeaders: false,
|
||||
message: 'Too many verification requests, please try again later',
|
||||
});
|
||||
|
||||
function checkSystemLoad(req, res, next) {
|
||||
const load = os.loadavg()[0];
|
||||
const cores = os.cpus().length;
|
||||
@@ -49,6 +65,8 @@ function respondWithStatusJSON(res, statusCode, JSON) {
|
||||
|
||||
export {
|
||||
requestLimiter,
|
||||
antiBruteForce,
|
||||
antiVerificationSpam,
|
||||
speedLimiter,
|
||||
checkSystemLoad,
|
||||
respondWithStatus,
|
||||
|
||||
Reference in New Issue
Block a user