Authored by 陈峰

Merge branch 'release/11.11' into 'release/6.7.9'

Release/11.11



See merge request !1553
... ... @@ -13,8 +13,9 @@ const isTest = process.env.NODE_ENV === 'test3';
const domains = {
// api: 'http://api.yoho.cn/',
// service: 'http://service.yoho.cn/',
api: 'http://api.yoho.cn/',
service: 'http://service.yoho.cn/',
// liveApi: 'http://testapi.live.yohops.com:9999/',
// singleApi: 'http://api-test3.yohops.com:9999/',
... ... @@ -24,8 +25,8 @@ const domains = {
// platformApi: 'http://172.16.6.210:8088/',
api: 'http://api-test3.dev.yohocorp.com/',
service: 'http://api-test3.dev.yohocorp.com/',
// api: 'http://api-test3.dev.yohocorp.com/',
// service: 'http://api-test3.dev.yohocorp.com/',
liveApi: 'http://testapi.live.yohops.com:9999/',
singleApi: 'http://api-test3.dev.yohocorp.com/',
... ... @@ -97,7 +98,7 @@ module.exports = {
}
},
console: {
level: 'info',
level: 'debug',
colorize: 'all',
prettyPrint: true,
debugStdout: true
... ...
... ... @@ -10,8 +10,6 @@ const sender = global.yoho.apmSender;
const config = global.yoho.config;
const hostname = require('os').hostname();
const routeEncode = require('./route-encode');
const pathWhiteList = require('./limiter/rules/path-white-list');
const ipWhiteList = require('./limiter/rules/ip-white-list');
const _ = require('lodash');
const replaceKey = '__refer__';
... ... @@ -125,7 +123,7 @@ exports.serverError = () => {
logger.error(err);
}
if (req.isApmReport && err.code !== 401) {
if (req.isApmReport && !err.apiError) {
// 上报服务端错误
sender.addMessage({
measurement: 'error-report',
... ... @@ -150,7 +148,7 @@ exports.serverError = () => {
});
}
if (err && err.code === 401) {
if (err.code === 401) {
logger.warn(`401 warn info:client_type=${req.query.client_type},req.user=${JSON.stringify(req.user)},req.query=${JSON.stringify(req.query)},cookies=${JSON.stringify(req.cookies)}`); // eslint-disable-line
if (req.xhr) {
... ... @@ -176,48 +174,27 @@ exports.serverError = () => {
refer: req.originalUrl
}));
}
} else if (err.apiRisk || err.code === 9999991 || err.code === 9999992) {
} else if (err.apiRisk) {
let remoteIp = req.yoho.clientIp;
if (!err.apiRisk && (_.includes(pathWhiteList(), req.path) || (await ipWhiteList(remoteIp)))) {
return _err510(req, res, 510, err);
}
if (remoteIp.indexOf(',') > 0) {
let arr = remoteIp.split(',');
remoteIp = arr[0];
}
let sessionLimitKey;
let isHuman;
if (err.apiRisk) {
sessionLimitKey = 'apiRiskValidate';
if (_.get(req.app.locals, 'wap.open.apmrisk', false)) {
cache.setAsync(`${config.app}:limit2:${remoteIp}`, 1, config.LIMITER_IP_TIME);
} else {
sessionLimitKey = 'apiLimitValidate';
isHuman = await cache.getAsync(`${config.app}:limiter:api:ishuman:${remoteIp}`);
cache.setAsync(`${config.app}:limiter:${remoteIp}`, 1, config.LIMITER_IP_TIME);
}
if (!isHuman) {
if (_.get(req.app.locals, 'wap.open.apmrisk', false)) {
cache.setAsync(`${config.app}:limit2:${remoteIp}`, 1, config.LIMITER_IP_TIME);
} else {
cache.setAsync(`${config.app}:limiter:${remoteIp}`, 1, config.LIMITER_IP_TIME);
}
req.session[sessionLimitKey] = true;
if (req.xhr) {
return res.status(510).json({
code: err.code,
data: {refer: checkRefer.replace(replaceKey, req.get('Referer') || '')}
});
}
req.session.apiRiskValidate = true;
return res.redirect(checkRefer.replace(replaceKey, req.protocol + '://' + req.get('host') + req.originalUrl));
if (req.xhr) {
return res.status(510).json({
code: err.code,
data: {refer: checkRefer.replace(replaceKey, req.get('Referer') || '')}
});
}
return res.redirect(checkRefer.replace(replaceKey, req.protocol + '://' + req.get('host') + req.originalUrl));
} else if (err.code === 9999991 || err.code === 9999992) {
return _err510(req, res, 510, err);
}
... ...
... ... @@ -88,7 +88,7 @@
"xml2js": "^0.4.19",
"yoho-express-session": "^2.0.0",
"yoho-md5": "^2.0.0",
"yoho-node-lib": "=0.6.33",
"yoho-node-lib": "=0.6.34",
"yoho-zookeeper": "^1.0.10"
},
"devDependencies": {
... ...