...
|
...
|
@@ -29,7 +29,7 @@ module.exports = (limiter, policy) => { |
|
|
|
|
|
const key = `pc:limiter:${limiter.remoteIp}`;
|
|
|
|
|
|
res.on('render', function() {
|
|
|
res.on('render', function () {
|
|
|
let route = req.route ? req.route.path : '';
|
|
|
let appPath = req.app.mountpath;
|
|
|
|
...
|
...
|
@@ -56,7 +56,10 @@ module.exports = (limiter, policy) => { |
|
|
return Promise.resolve(true);
|
|
|
}
|
|
|
|
|
|
if (result > MAX_QPS) { // 判断 qps
|
|
|
if (result === 9999) {
|
|
|
res.statusCode = 403;
|
|
|
return Promise.resolve(policy);
|
|
|
} else if (result > MAX_QPS) { // 判断 qps
|
|
|
cache.touch(key, ONE_DAY);
|
|
|
logger.debug('req limit', key);
|
|
|
|
...
|
...
|
@@ -67,7 +70,7 @@ module.exports = (limiter, policy) => { |
|
|
|
|
|
}
|
|
|
} else {
|
|
|
cache.setAsync(key, 1, 60); // 设置key,1m失效
|
|
|
cache.setAsync(key, 1, 60); // 设置key,1m失效
|
|
|
return Promise.resolve(true);
|
|
|
}
|
|
|
});
|
...
|
...
|
|