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