Skip to content

Commit

Permalink
[FEATURE] IP 추출 로직 수정 (#128)
Browse files Browse the repository at this point in the history
feat: IP 추출 로직 수정 (#127)
  • Loading branch information
hyunmin0317 authored Dec 24, 2024
1 parent f4f3855 commit 338bf7f
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ public static String getClientIp(HttpServletRequest request) {
return IP_HEADER_CANDIDATES.stream()
.map(request::getHeader)
.filter(IpUtil::isValidIp)
.map(IpUtil::extractFirstIp)
.findFirst()
.orElseGet(request::getRemoteAddr);
}

private static boolean isValidIp(String ip) {
return ip != null && !ip.isEmpty() && !"unknown".equalsIgnoreCase(ip);
}

private static String extractFirstIp(String ip) {
return ip.split(",")[0].trim();
}
}

0 comments on commit 338bf7f

Please sign in to comment.