Authored by 姜枫

Merge branch 'feature/anti-spider' into 'master'

Change log level to debug



See merge request !79
... ... @@ -20,7 +20,7 @@ const limiter = (rule, policy, context) => {
module.exports = (req, res, next) => {
let remoteIp = req.get('X-Forwarded-For') || req.connection.remoteAddress;
logger.info('request remote ip: ', remoteIp);
logger.debug('request remote ip: ', remoteIp);
if (remoteIp.indexOf(',') > 0) {
let arr = remoteIp.split(',');
... ... @@ -44,11 +44,11 @@ module.exports = (req, res, next) => {
limiter(userAgent, captchaPolicy, context),
limiter(ip, captchaPolicy, context),
limiter(qpsLimiter, captchaPolicy, context),
limiter(fakerLimiter, reporterPolicy, context)
//limiter(fakerLimiter, reporterPolicy, context)
]).then((results) => {
let allPass = true, exclusion = false, policy = null;
logger.info('limiter result: ' + JSON.stringify(results));
logger.debug('limiter result: ' + JSON.stringify(results));
_.forEach(results, (result) => {
if (typeof result === 'object' && !exclusion) {
... ...
... ... @@ -22,7 +22,7 @@ module.exports = (limiter, policy) => {
return cache.getAsync(key).then((result) => {
if (result) {
if (result > 100) {
return policy(req, res, next);
return Promise.resolve(policy);//policy(req, res, next);
} else {
return Promise.resolve(true);
}
... ...
... ... @@ -50,7 +50,7 @@ module.exports = (limiter, policy) => {
});
return cache.getAsync(key).then((result) => {
logger.info('qps limiter: ' + key + '@' + result + ' max: ' + MAX_QPS);
logger.debug('qps limiter: ' + key + '@' + result + ' max: ' + MAX_QPS);
if (result && _.isNumber(result)) {
... ... @@ -60,7 +60,7 @@ module.exports = (limiter, policy) => {
if (result > MAX_QPS) { // 判断 qps
cache.touch(key, ONE_DAY);
logger.info('req limit', key);
logger.debug('req limit', key);
return Promise.resolve(policy);
} else {
... ...