|
|
|
@ -27,6 +27,7 @@ import java.util.stream.Collectors;
|
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
|
|
|
import javax.imageio.ImageIO;
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.io.FilenameUtils;
|
|
|
|
|
import org.springframework.core.io.ClassPathResource;
|
|
|
|
@ -606,4 +607,33 @@ public class CmmnUtil {
|
|
|
|
|
return mm * 2.83465f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 클라이언트 IP를 반환한다.
|
|
|
|
|
* @param request 서블릿 요청
|
|
|
|
|
* @return 클라이언트 IP
|
|
|
|
|
*/
|
|
|
|
|
public static String getClientIpAddr(HttpServletRequest request) {
|
|
|
|
|
String REGEXP_IPV4_ADDR = "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$";
|
|
|
|
|
String[] headerNames = {"X-Forwarded-For","Proxy-Client-IP","WL-Proxy-Client-IP","HTTP_CLIENT_IP","HTTP_X_FORWARDED_FOR"};
|
|
|
|
|
|
|
|
|
|
String ip = "";
|
|
|
|
|
for(String headerName : headerNames) {
|
|
|
|
|
ip = request.getHeader(headerName);
|
|
|
|
|
if(ip != null && ip.contains(",")) {
|
|
|
|
|
ip = ip.split(",",-1)[0];
|
|
|
|
|
}
|
|
|
|
|
if(ip != null && Pattern.matches(REGEXP_IPV4_ADDR, ip)) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(ip != null && ip.contains(",")) {
|
|
|
|
|
ip = ip.split(",",-1)[0];
|
|
|
|
|
}
|
|
|
|
|
if(ip == null || !Pattern.matches(REGEXP_IPV4_ADDR, ip)) {
|
|
|
|
|
ip = request.getRemoteAddr();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ip;
|
|
|
|
|
}
|
|
|
|
|
}
|