...
|
...
|
@@ -10,6 +10,7 @@ const uuid = require('uuid'); |
|
|
const _ = require('lodash');
|
|
|
const config = global.yoho.config;
|
|
|
const helpers = global.yoho.helpers;
|
|
|
const net = require('net');
|
|
|
|
|
|
const _getGender = (channel) => {
|
|
|
switch (channel) {
|
...
|
...
|
@@ -64,15 +65,27 @@ module.exports = () => { |
|
|
|
|
|
// 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;
|
|
|
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 = arr[arr.length - 1];
|
|
|
remoteIp = _.trim(arr[0]);
|
|
|
}
|
|
|
|
|
|
return _.trim(remoteIp);
|
|
|
if (_.startsWith(remoteIp, '10.66.')) {
|
|
|
remoteIp = req.get('X-Real-IP');
|
|
|
}
|
|
|
|
|
|
remoteIp = _.trim(remoteIp);
|
|
|
|
|
|
if (!net.isIPv4(remoteIp)) {
|
|
|
let ipv6String = remoteIp.split(':');
|
|
|
|
|
|
remoteIp = ipv6String[ipv6String.length - 1];
|
|
|
}
|
|
|
|
|
|
return remoteIp;
|
|
|
}());
|
|
|
|
|
|
|
...
|
...
|
|