From 4fd062fa1a36c2d914ee1f1b89e8c5f9d17a1bda Mon Sep 17 00:00:00 2001 From: leebj Date: Wed, 10 Jul 2024 09:41:51 +0900 Subject: [PATCH] =?UTF-8?q?=EC=A0=91=EC=86=8D=EC=9E=90=20ip=20=ED=99=95?= =?UTF-8?q?=EC=9D=B8=20=EB=A9=94=EC=86=8C=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xit/fims/base/web/MainController.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/main/java/cokr/xit/fims/base/web/MainController.java b/src/main/java/cokr/xit/fims/base/web/MainController.java index ca7c0ae4..76907aa4 100644 --- a/src/main/java/cokr/xit/fims/base/web/MainController.java +++ b/src/main/java/cokr/xit/fims/base/web/MainController.java @@ -3,6 +3,7 @@ package cokr.xit.fims.base.web; import java.util.List; import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -130,5 +131,39 @@ public class MainController extends cokr.xit.base.web.MainController { .addObject("duplicate", user != null); } + @RequestMapping(name="접속자 IP 확인", value="/ipInfo.do") + public ModelAndView ipInfo(HttpServletRequest hreq) { + + String remoteAddr = hreq.getRemoteAddr(); + String net = ""; + String LOCAL = "127.0.0.1"; + String[] PRIVATES = {"10.","172.16.","172.31.","192.168."}; + String[] SGG_NET = {"211.119.124."}; + + if(remoteAddr.equals(LOCAL)) { + String flag = hreq.getParameter("flag"); + if(flag != null && !flag.equals("")){ + net = flag; + } else { + net = "intra"; + } + } else if(remoteAddr.startsWith(PRIVATES[0]) + || remoteAddr.startsWith(PRIVATES[1]) + || remoteAddr.startsWith(PRIVATES[2]) + || remoteAddr.startsWith(PRIVATES[3])){ + net = "intra"; + } else if(SGG_NET.length > 0){ + for(String sgg : SGG_NET) { + if(remoteAddr.startsWith(sgg)) { + net = "intra"; + } + } + } else { + net = "inter"; + } + return new ModelAndView("jsonView") + .addObject("remoteAddr", remoteAddr) + .addObject("net", net); + } } \ No newline at end of file