mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-08-26 19:26:05 +02:00
@@ -12,33 +12,7 @@ module.exports = function (middleware) {
|
||||
}
|
||||
var url = req.url.replace(nconf.get('relative_path'), '');
|
||||
|
||||
var allowedRoutes = [
|
||||
'^/ping',
|
||||
'^/sping',
|
||||
'^/login',
|
||||
'^/stylesheet.css',
|
||||
'^/favicon',
|
||||
'^/nodebb.min.js',
|
||||
'^/vendor/fontawesome/fonts/fontawesome-webfont.woff',
|
||||
'^/src/(modules|client)/[\\w/]+.js',
|
||||
'^/templates/[\\w/]+.tpl',
|
||||
'^/api/login',
|
||||
'^/api/widgets/render',
|
||||
'^/public/language',
|
||||
'^/uploads/system/site-logo.png'
|
||||
];
|
||||
|
||||
var isAllowed = function (url) {
|
||||
for(var x = 0,numAllowed = allowedRoutes.length,route; x < numAllowed; x++) {
|
||||
route = new RegExp(allowedRoutes[x]);
|
||||
if (route.test(url)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
if (isAllowed(url)) {
|
||||
if (url.startsWith('/login') || url.startsWith('/api/login')) {
|
||||
return next();
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
'use strict';
|
||||
var winston = require('winston');
|
||||
|
||||
var ratelimit = {};
|
||||
var ratelimit = module.exports;
|
||||
|
||||
var allowedCalls = 100;
|
||||
var timeframe = 10000;
|
||||
@@ -31,5 +31,3 @@ ratelimit.isFlooding = function (socket) {
|
||||
socket.lastCallTime = now;
|
||||
return false;
|
||||
};
|
||||
|
||||
module.exports = ratelimit;
|
||||
|
||||
Reference in New Issue
Block a user