Authored by 毕凯

Merge branch 'hotfix/ipv6' into 'release/5.8'

ipv6



See merge request !662
... ... @@ -7,6 +7,7 @@
'use strict';
const _ = require('lodash');
const helpers = global.yoho.helpers;
const net = require('net');
/**
* 获取 IP
... ... @@ -25,7 +26,15 @@ const _getClientIp = req => {
remoteIp = req.get('X-Real-IP');
}
return _.trim(remoteIp);
remoteIp = _.trim(remoteIp);
if (!net.isIPv4(remoteIp)) {
let ipv6String = remoteIp.split(':');
remoteIp = ipv6String[ipv6String.length - 1];
}
return remoteIp;
};
module.exports = () => {
... ...