瀏覽代碼

Fix monitoring being blocked

Gaël Métais 4 年之前
父節點
當前提交
fcdf3c9240
共有 2 個文件被更改,包括 9 次插入1 次删除
  1. 1 1
      lib/metadata/policies.js
  2. 8 0
      lib/server/middlewares/apiLimitsMiddleware.js

+ 1 - 1
lib/metadata/policies.js

@@ -538,7 +538,7 @@ var policies = {
         "message": "<p>It can be useful, but only as a last resort. It is a bad practice because it overrides the normal cascading logic. The more you use !important, the more you need it again to over-override. This conducts to a poor maintainability.</p>",
         "isOkThreshold": 0,
         "isBadThreshold": 200,
-        "isAbnormalThreshold": 500,
+        "isAbnormalThreshold": 1000,
         "hasOffenders": true,
         "offendersTransformFn": function(offenders) {
             var parsedOffenders = offenders.map(function(offender) {

+ 8 - 0
lib/server/middlewares/apiLimitsMiddleware.js

@@ -13,6 +13,13 @@ var apiLimitsMiddleware = function(req, res, next) {
     if (req.path.indexOf('/api/') === 0 && !res.locals.hasApiKey) {
         
         
+        // Monitoring requests
+        if (req.path === '/api/runs' && req.method === 'GET') {
+            next();
+            return;
+        }
+
+        // New tests 
         if (req.path === '/api/runs' && req.method === 'POST') {
             
             if (!runsTable.accepts(ipAddress)) {
@@ -24,6 +31,7 @@ var apiLimitsMiddleware = function(req, res, next) {
 
         }
 
+        // Every other calls
         if (!callsTable.accepts(ipAddress)) {
             // Sorry :/
             debug('Too many API requests from IP address %s', ipAddress);