private-route.js
564 Bytes
const _ = require('lodash');
const logger = global.yoho.logger;
module.exports = (req, res, next) => {
try {
const privateIps = _.get(req, 'app.locals.yap.json.privateips', []);
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();
}
} catch (error) {
logger.error('[privateips error], ', error);
}
logger.warn(`[privateips warn], ${req.yoho.clientIp}`);
return next();
};