Skip to content

Commit

Permalink
fix: ip error (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
CxyJerry authored Nov 18, 2023
1 parent 3843612 commit 39ccf3e
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.jerry.pilipala.infrastructure.utils;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

import javax.servlet.http.HttpServletRequest;
import java.net.InetAddress;
Expand Down Expand Up @@ -34,11 +35,11 @@ public static String getIpAddress(HttpServletRequest request) {
String ip = null;
for (String config : HEADER_CONFIG) {
ip = request.getHeader(config);
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
if (StringUtils.isNotBlank(ip) || "unknown".equalsIgnoreCase(ip)) {
break;
}
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
if (StringUtils.isBlank(ip) || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
if ("0:0:0:0:0:0:0:1".equals(ip)) {
Expand Down

0 comments on commit 39ccf3e

Please sign in to comment.