Commit 4ee1aea128bbd15523db4bf84e1f7d288baf9b5a

Authored by JEECG官方
Committed by Gitee
1 parent 0341a3d2

删除文件 jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/com…

…mon/util/IPUtils.java
jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/IPUtils.java deleted
1   -package org.jeecg.common.util;
2   -
3   -import javax.servlet.http.HttpServletRequest;
4   -
5   -import org.apache.commons.lang3.StringUtils;
6   -import org.jeecg.common.constant.CommonConstant;
7   -import org.slf4j.Logger;
8   -import org.slf4j.LoggerFactory;
9   -
10   -/**
11   - * IP地址
12   - *
13   - * @Author scott
14   - * @email jeecgos@163.com
15   - * @Date 2019年01月14日
16   - */
17   -public class IpUtils {
18   - private static Logger logger = LoggerFactory.getLogger(IpUtils.class);
19   -
20   - /**
21   - * 获取IP地址
22   - *
23   - * 使用Nginx等反向代理软件, 则不能通过request.getRemoteAddr()获取IP地址
24   - * 如果使用了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP地址,X-Forwarded-For中第一个非unknown的有效IP字符串,则为真实IP地址
25   - */
26   - public static String getIpAddr(HttpServletRequest request) {
27   - String ip = null;
28   - try {
29   - ip = request.getHeader("x-forwarded-for");
30   - if (StringUtils.isEmpty(ip) || CommonConstant.UNKNOWN.equalsIgnoreCase(ip)) {
31   - ip = request.getHeader("Proxy-Client-IP");
32   - }
33   - if (StringUtils.isEmpty(ip) || ip.length() == 0 ||CommonConstant.UNKNOWN.equalsIgnoreCase(ip)) {
34   - ip = request.getHeader("WL-Proxy-Client-IP");
35   - }
36   - if (StringUtils.isEmpty(ip) || CommonConstant.UNKNOWN.equalsIgnoreCase(ip)) {
37   - ip = request.getHeader("HTTP_CLIENT_IP");
38   - }
39   - if (StringUtils.isEmpty(ip) || CommonConstant.UNKNOWN.equalsIgnoreCase(ip)) {
40   - ip = request.getHeader("HTTP_X_FORWARDED_FOR");
41   - }
42   - if (StringUtils.isEmpty(ip) || CommonConstant.UNKNOWN.equalsIgnoreCase(ip)) {
43   - ip = request.getRemoteAddr();
44   - }
45   - } catch (Exception e) {
46   - logger.error("IPUtils ERROR ", e);
47   - }
48   -
49   -// //使用代理,则获取第一个IP地址
50   -// if(StringUtils.isEmpty(ip) && ip.length() > 15) {
51   -// if(ip.indexOf(",") > 0) {
52   -// ip = ip.substring(0, ip.indexOf(","));
53   -// }
54   -// }
55   -
56   - return ip;
57   - }
58   -
59   -}