feat: 添加slrs业务子项目 修改问题文件

This commit is contained in:
super_liu
2021-05-31 17:18:43 +08:00
parent dd50eaebf4
commit 230889c3ff
92 changed files with 6765 additions and 31 deletions
@@ -0,0 +1,49 @@
package com.adc.da.util;
import org.apache.commons.lang3.StringUtils;
import javax.servlet.http.HttpServletRequest;
public class IpUtil {
private IpUtil() {
throw new IllegalStateException("Utility class");
}
private static boolean checkIp(String ip) {
return ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip);
}
public static String getIpAddr(HttpServletRequest request) {
String ip = request.getHeader("X-Forwarded-For");
if (checkIp(ip)) {
ip = request.getHeader("Proxy-Client-IP");
if (checkIp(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (checkIp(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if (checkIp(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (checkIp(ip)) {
ip = request.getRemoteAddr();
}
} else if (ip.length() > 15) {
String[] ips = ip.split(",");
for(int index = 0; index < ips.length; ++index) {
String strIp = ips[index];
if (!"unknown".equalsIgnoreCase(strIp)) {
ip = strIp;
break;
}
}
}
return StringUtils.trim(ip);
}
}