접속자 ip 확인 메소드 추가

main
이범준 4 months ago
parent 5b87416a72
commit 4fd062fa1a

@ -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);
}
}
Loading…
Cancel
Save