Authored by htoooth

merge master

... ... @@ -201,6 +201,6 @@ router.get('/passport/back/resetSuccess',
router.get('/passport/imagesNode', captcha.generate);
router.post('/passport/captcha/img', captcha.checkAPI);
router.get('/passport/images', captcha.generateQiniu);
router.get('/passport/images.png', captcha.generateQiniu);
module.exports = router;
... ...
... ... @@ -10,9 +10,9 @@ const captchaPolicy = require('./policies/captcha');
const reporterPolicy = require('./policies/reporter');
const IP_WHITE_LIST = [
// '106.38.38.146',
// '218.94.75.58'
'106.38.38.146',
'218.94.75.58',
'218.94.75.50'
];
const limiter = (rule, policy, context) => {
... ... @@ -20,7 +20,7 @@ const limiter = (rule, policy, context) => {
};
module.exports = (req, res, next) => {
let remoteIp = req.get('X-Forwarded-For') || req.connection.remoteAddress;
let remoteIp = req.get('X-Forwarded-For') || req.get('X-Real-IP') || '';
if (remoteIp.indexOf(',') > 0) {
let arr = remoteIp.split(',');
... ... @@ -30,6 +30,10 @@ module.exports = (req, res, next) => {
remoteIp = _.trim(remoteIp);
if (_.startsWith(remoteIp, '10.66.')) {
remoteIp = req.get('X-Real-IP');
}
logger.info('request remote ip: ', remoteIp);
const excluded = _.includes(IP_WHITE_LIST, remoteIp);
... ...
... ... @@ -6,6 +6,7 @@ const _ = require('lodash');
const WHITE_LIST = [
'/3party/check',
'/passport/imagesNode',
'/passport/images.png',
'/passport/cert/headerTip'
];
... ...
{
"name": "yohobuy-node",
"version": "5.4.23",
"version": "5.4.25",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ... @@ -56,6 +56,7 @@
"passport-sina": "^0.1.0",
"passport-strategy": "1.x.x",
"passport-weixin": "^0.1.0",
"request": "^2.81.0",
"request-ip": "^1.2.2",
"request-promise": "^3.0.0",
"serve-favicon": "^2.3.0",
... ...
... ... @@ -5,7 +5,7 @@
var Captcha = function(container, options) {
var optionDefault = {
template: require('hbs/common/captcha.hbs'),
refreshURI: '/passport/images',
refreshURI: '/passport/images.png',
checkURI: '/passport/captcha/img'
};
... ...