提交 17151677 编写于 作者: M mxd

fix

上级 0bff6c55
...@@ -11,11 +11,11 @@ public class IpUtils { ...@@ -11,11 +11,11 @@ public class IpUtils {
private static final String[] DEFAULT_IP_HEADER = new String[]{"X-Forwarded-For", "X-Real-IP", "Proxy-Client-IP", "WL-Proxy-Client-IP", "HTTP_CLIENT_IP", "HTTP_X_FORWARDED_FOR"}; private static final String[] DEFAULT_IP_HEADER = new String[]{"X-Forwarded-For", "X-Real-IP", "Proxy-Client-IP", "WL-Proxy-Client-IP", "HTTP_CLIENT_IP", "HTTP_X_FORWARDED_FOR"};
public static String getRealIP(String remoteAddr, Function<String, String> getHeader, String ... otherHeaderNames){ public static String getRealIP(String remoteAddr, Function<String, String> getHeader, String... otherHeaderNames) {
String ip = null; String ip = null;
List<String> headers = Stream.concat(Stream.of(DEFAULT_IP_HEADER), Stream.of(otherHeaderNames)).collect(Collectors.toList()); List<String> headers = Stream.concat(Stream.of(DEFAULT_IP_HEADER), Stream.of(otherHeaderNames == null ? new String[0] : otherHeaderNames)).collect(Collectors.toList());
for (String header : headers) { for (String header : headers) {
if((ip = processIp(getHeader.apply(header))) != null){ if ((ip = processIp(getHeader.apply(header))) != null) {
break; break;
} }
} }
...@@ -42,7 +42,7 @@ public class IpUtils { ...@@ -42,7 +42,7 @@ public class IpUtils {
return null; return null;
} }
private static boolean isUnknown(String ip) { private static boolean isUnknown(String ip) {
return StringUtils.isBlank(ip) || "unknown".equalsIgnoreCase(ip.trim()); return StringUtils.isBlank(ip) || "unknown".equalsIgnoreCase(ip.trim());
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册