Authored by 刘志远

Merge branch 'feature/del-privateIps' into 'master'

去掉ip 限制

去掉ip 限制

See merge request !107
... ... @@ -2,16 +2,18 @@ const _ = require('lodash');
const logger = global.yoho.logger;
module.exports = (req, res, next) => {
try {
const privateIps = _.get(req, 'app.locals.yap.json.privateips', []);
try {
const privateIps = _.get(req, 'app.locals.yap.json.privateips', []);
if (_.includes(privateIps, req.yoho.clientIp) || _.get(req, 'app.locals.devEnv', false ) ||
_.get(req, 'app.locals.isTest', false)) {
return next();
}
} catch (error) {
logger.error('[privateips error], ', error);
logger.info(`privateIps: ${privateIps.join(',')}`);
if (_.includes(privateIps, req.yoho.clientIp) || _.get(req, 'app.locals.devEnv', false) ||
_.get(req, 'app.locals.isTest', false)) {
return next();
}
logger.warn(`[privateips warn], ${req.yoho.clientIp}`);
return res.status(401).end();
} catch (error) {
logger.error('[privateips error], ', error);
}
logger.warn(`[privateips warn], ${req.yoho.clientIp}`);
return next();
};
... ...