Showing
3 changed files
with
2 additions
and
15 deletions
@@ -412,7 +412,7 @@ function getRealIP(req) { | @@ -412,7 +412,7 @@ function getRealIP(req) { | ||
412 | var realIP = req.headers['x-real-ip']; | 412 | var realIP = req.headers['x-real-ip']; |
413 | var forwardedFor = req.headers['x-forwarded-for'] || ''; | 413 | var forwardedFor = req.headers['x-forwarded-for'] || ''; |
414 | 414 | ||
415 | - return realIP || forwardedFor.split(',')[0] || req.connection.remoteAddress; | 415 | + return req.yoho.clientIp || forwardedFor.split(',')[0] || realIP || req.connection.remoteAddress; |
416 | } | 416 | } |
417 | 417 | ||
418 | const activateService = (req, res, next) => { | 418 | const activateService = (req, res, next) => { |
@@ -53,19 +53,7 @@ const limiter = (rule, policy, context) => { | @@ -53,19 +53,7 @@ const limiter = (rule, policy, context) => { | ||
53 | }; | 53 | }; |
54 | 54 | ||
55 | module.exports = (req, res, next) => { | 55 | module.exports = (req, res, next) => { |
56 | - let remoteIp = req.get('X-Yoho-Real-IP') || req.get('X-Forwarded-For') || req.get('X-Real-IP') || ''; | ||
57 | - | ||
58 | - if (remoteIp.indexOf(',') > 0) { | ||
59 | - let arr = remoteIp.split(','); | ||
60 | - | ||
61 | - remoteIp = arr[arr.length - 1]; | ||
62 | - } | ||
63 | - | ||
64 | - if (_.startsWith(remoteIp, '10.66.')) { | ||
65 | - remoteIp = req.get('X-Real-IP'); | ||
66 | - } | ||
67 | - | ||
68 | - remoteIp = _.trim(remoteIp); | 56 | + let remoteIp = req.yoho.clientIp || ''; |
69 | 57 | ||
70 | // 排除条件:ip白名单/路径白名单/异步请求/登录用户 | 58 | // 排除条件:ip白名单/路径白名单/异步请求/登录用户 |
71 | const excluded = _.includes(IP_WHITE_LIST, remoteIp) || | 59 | const excluded = _.includes(IP_WHITE_LIST, remoteIp) || |
@@ -7,7 +7,6 @@ | @@ -7,7 +7,6 @@ | ||
7 | 'use strict'; | 7 | 'use strict'; |
8 | const _ = require('lodash'); | 8 | const _ = require('lodash'); |
9 | const helpers = global.yoho.helpers; | 9 | const helpers = global.yoho.helpers; |
10 | -const logger = global.yoho.logger; | ||
11 | const net = require('net'); | 10 | const net = require('net'); |
12 | 11 | ||
13 | /** | 12 | /** |
-
Please register or login to post a comment