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) => { @@ -20,7 +20,7 @@ const limiter = (rule, policy, context) => {
20 20
21 module.exports = (req, res, next) => { 21 module.exports = (req, res, next) => {
22 let remoteIp = req.get('X-Forwarded-For') || req.connection.remoteAddress; 22 let remoteIp = req.get('X-Forwarded-For') || req.connection.remoteAddress;
23 - logger.info('request remote ip: ', remoteIp); 23 + logger.debug('request remote ip: ', remoteIp);
24 24
25 if (remoteIp.indexOf(',') > 0) { 25 if (remoteIp.indexOf(',') > 0) {
26 let arr = remoteIp.split(','); 26 let arr = remoteIp.split(',');
@@ -44,11 +44,11 @@ module.exports = (req, res, next) => { @@ -44,11 +44,11 @@ module.exports = (req, res, next) => {
44 limiter(userAgent, captchaPolicy, context), 44 limiter(userAgent, captchaPolicy, context),
45 limiter(ip, captchaPolicy, context), 45 limiter(ip, captchaPolicy, context),
46 limiter(qpsLimiter, captchaPolicy, context), 46 limiter(qpsLimiter, captchaPolicy, context),
47 - limiter(fakerLimiter, reporterPolicy, context) 47 + //limiter(fakerLimiter, reporterPolicy, context)
48 ]).then((results) => { 48 ]).then((results) => {
49 let allPass = true, exclusion = false, policy = null; 49 let allPass = true, exclusion = false, policy = null;
50 50
51 - logger.info('limiter result: ' + JSON.stringify(results)); 51 + logger.debug('limiter result: ' + JSON.stringify(results));
52 52
53 _.forEach(results, (result) => { 53 _.forEach(results, (result) => {
54 if (typeof result === 'object' && !exclusion) { 54 if (typeof result === 'object' && !exclusion) {
@@ -22,7 +22,7 @@ module.exports = (limiter, policy) => { @@ -22,7 +22,7 @@ module.exports = (limiter, policy) => {
22 return cache.getAsync(key).then((result) => { 22 return cache.getAsync(key).then((result) => {
23 if (result) { 23 if (result) {
24 if (result > 100) { 24 if (result > 100) {
25 - return policy(req, res, next); 25 + return Promise.resolve(policy);//policy(req, res, next);
26 } else { 26 } else {
27 return Promise.resolve(true); 27 return Promise.resolve(true);
28 } 28 }
@@ -50,7 +50,7 @@ module.exports = (limiter, policy) => { @@ -50,7 +50,7 @@ module.exports = (limiter, policy) => {
50 }); 50 });
51 51
52 return cache.getAsync(key).then((result) => { 52 return cache.getAsync(key).then((result) => {
53 - logger.info('qps limiter: ' + key + '@' + result + ' max: ' + MAX_QPS); 53 + logger.debug('qps limiter: ' + key + '@' + result + ' max: ' + MAX_QPS);
54 54
55 if (result && _.isNumber(result)) { 55 if (result && _.isNumber(result)) {
56 56
@@ -60,7 +60,7 @@ module.exports = (limiter, policy) => { @@ -60,7 +60,7 @@ module.exports = (limiter, policy) => {
60 60
61 if (result > MAX_QPS) { // 判断 qps 61 if (result > MAX_QPS) { // 判断 qps
62 cache.touch(key, ONE_DAY); 62 cache.touch(key, ONE_DAY);
63 - logger.info('req limit', key); 63 + logger.debug('req limit', key);
64 64
65 return Promise.resolve(policy); 65 return Promise.resolve(policy);
66 } else { 66 } else {