...
|
...
|
@@ -6,6 +6,8 @@ |
|
|
|
|
|
'use strict';
|
|
|
|
|
|
const _ = require('lodash');
|
|
|
|
|
|
module.exports = () => {
|
|
|
return (req, res, next) => {
|
|
|
const channelMap = {
|
...
|
...
|
@@ -43,6 +45,25 @@ module.exports = () => { |
|
|
yoho.isAndroid = /Android/i.test(userAgent);
|
|
|
yoho.isYohoBuy = /YohoBuy/i.test(userAgent);
|
|
|
|
|
|
// client ip
|
|
|
yoho.clientIp = (function() {
|
|
|
let remoteIp = req.get('X-Yoho-Real-IP') || req.get('X-Forwarded-For') || req.get('X-Real-IP') || req.ip || ''; // eslint-disable-line
|
|
|
|
|
|
if (remoteIp.indexOf(',') > 0) {
|
|
|
let arr = remoteIp.split(',');
|
|
|
|
|
|
remoteIp = _.trim(arr[0]);
|
|
|
}
|
|
|
|
|
|
if (_.startsWith(remoteIp, '10.66.')) {
|
|
|
remoteIp = req.get('X-Real-IP');
|
|
|
}
|
|
|
|
|
|
remoteIp = _.trim(remoteIp);
|
|
|
|
|
|
return remoteIp;
|
|
|
}());
|
|
|
|
|
|
Object.assign(res.locals, yoho);
|
|
|
Object.assign(req.yoho, yoho);
|
|
|
|
...
|
...
|
|