...
|
...
|
@@ -38,10 +38,9 @@ module.exports = async({user}, next) => { |
|
|
|
|
|
const ip = user.ip;
|
|
|
const path = user.path;
|
|
|
const risks = _.get(zk, `${app}.json.risk`, []);
|
|
|
const risks = _.get(zk, `${app}.json.risk`, [{route: '/product/(.*).html', interval: 5000, requests: 10}]);
|
|
|
let router = {};
|
|
|
|
|
|
logger.debug(`risk => risks: ${JSON.stringify(risks)}, path: ${path}, ip: ${ip}`); // eslint-disable-line
|
|
|
if (_.isEmpty(path) || _.isEmpty(risks) || IP_WHITE_LIST.indexOf(ip) > -1) {
|
|
|
return next();
|
|
|
}
|
...
|
...
|
@@ -65,7 +64,8 @@ module.exports = async({user}, next) => { |
|
|
return false;
|
|
|
});
|
|
|
|
|
|
logger.debug(`risk => router: ${JSON.stringify(router)}, path: ${path}`); // eslint-disable-line
|
|
|
logger.debug(`risk==> router: ${JSON.stringify(router)}, path: ${path}`); // eslint-disable-line
|
|
|
|
|
|
if (_.isEmpty(router)) {
|
|
|
return next();
|
|
|
}
|
...
|
...
|
@@ -79,9 +79,8 @@ module.exports = async({user}, next) => { |
|
|
cache.getAsync(configKey),
|
|
|
]);
|
|
|
|
|
|
logger.debug(`risk => getCache: ${JSON.stringify(inters)}, path: ${path}`); // eslint-disable-line
|
|
|
if (inters[0]) {
|
|
|
logger.info('[qps:route] this user[%o] has rejected', user);
|
|
|
logger.info('[qps:route] this user[%j] has rejected', user);
|
|
|
return;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -97,7 +96,7 @@ module.exports = async({user}, next) => { |
|
|
return next();
|
|
|
}
|
|
|
|
|
|
logger.warn('[qps:route] this user[%o] is being marked as rejected', user);
|
|
|
logger.info('[qps:route] this user[%j] is being marked as rejected', user);
|
|
|
await Promise.all([
|
|
|
cache.setAsync(limitKey, 1, INVALIDTIME),
|
|
|
cache.delAsync(configKey)
|
...
|
...
|
|