Merge branch 'zhaoyue-dev4' into 'master'
Mod get real ip See merge request !61
Showing
1 changed file
with
6 additions
and
1 deletions
@@ -49,7 +49,12 @@ public class CurrentAdminMethodArgumentResolver implements HandlerMethodArgument | @@ -49,7 +49,12 @@ public class CurrentAdminMethodArgumentResolver implements HandlerMethodArgument | ||
49 | //从数据库中查询并返回 | 49 | //从数据库中查询并返回 |
50 | XklAdminEntity admin = adminRepository.findByIdAndStatus(Long.parseLong(currentAdminId), Constants.STATUS_OK); | 50 | XklAdminEntity admin = adminRepository.findByIdAndStatus(Long.parseLong(currentAdminId), Constants.STATUS_OK); |
51 | HttpServletRequest request = ((ServletWebRequest) webRequest).getRequest(); | 51 | HttpServletRequest request = ((ServletWebRequest) webRequest).getRequest(); |
52 | - String ip = request.getRemoteAddr(); | 52 | + String ip = null; |
53 | + if (request.getHeader("x-forwarded-for") == null) { | ||
54 | + ip = request.getRemoteAddr(); | ||
55 | + } else { | ||
56 | + ip = request.getHeader("x-forwarded-for"); | ||
57 | + } | ||
53 | admin.setIp(ip); | 58 | admin.setIp(ip); |
54 | return admin; | 59 | return admin; |
55 | } | 60 | } |
-
Please register or login to post a comment