From 338bf7fb0519785425970b2ce82f24bf45693419 Mon Sep 17 00:00:00 2001 From: Hyunmin Choi Date: Tue, 24 Dec 2024 20:28:38 +0900 Subject: [PATCH] =?UTF-8?q?[FEATURE]=20IP=20=EC=B6=94=EC=B6=9C=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=88=98=EC=A0=95=20(#128)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit feat: IP 추출 로직 수정 (#127) --- .../java/com/smunity/server/domain/account/util/IpUtil.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/smunity/server/domain/account/util/IpUtil.java b/src/main/java/com/smunity/server/domain/account/util/IpUtil.java index e4c085d..1d42e84 100644 --- a/src/main/java/com/smunity/server/domain/account/util/IpUtil.java +++ b/src/main/java/com/smunity/server/domain/account/util/IpUtil.java @@ -16,6 +16,7 @@ public static String getClientIp(HttpServletRequest request) { return IP_HEADER_CANDIDATES.stream() .map(request::getHeader) .filter(IpUtil::isValidIp) + .map(IpUtil::extractFirstIp) .findFirst() .orElseGet(request::getRemoteAddr); } @@ -23,4 +24,8 @@ public static String getClientIp(HttpServletRequest request) { 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(); + } }