|
@@ -883,10 +883,7 @@ public class ExamServiceImpl implements ExamService {
|
|
|
DynamicEnum ipCenterLimit = manager.getByName("IP_CENTER_LIMIT");
|
|
|
|
|
|
if (ipLimited) {
|
|
|
- String realIp = request.getHeader("x-forwarded-for");
|
|
|
- if (StringUtils.isBlank(realIp)) {
|
|
|
- realIp = request.getHeader("x-real-ip");
|
|
|
- }
|
|
|
+ String realIp = getIp(request);
|
|
|
realIp = realIp.trim();
|
|
|
//整体控制
|
|
|
Integer totalLimit = getExamLimitProperty(examId, ipTotalLimit.getId(), 0);
|
|
@@ -933,6 +930,20 @@ public class ExamServiceImpl implements ExamService {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ private String getIp(HttpServletRequest request) {
|
|
|
+ String ip = request.getHeader("x-forwarded-for");
|
|
|
+ if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
|
|
+ ip = request.getHeader("Proxy-Client-IP");
|
|
|
+ }
|
|
|
+ if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
|
|
+ ip = request.getHeader("WL-Proxy-Client-IP");
|
|
|
+ }
|
|
|
+ if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
|
|
+ ip = request.getRemoteAddr();
|
|
|
+ }
|
|
|
+ return ip.equals("0:0:0:0:0:0:0:1")?"127.0.0.1":ip;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void saveIpLimit(String ids, ExamIpLimitEntity entity) {
|
|
|
//ids不为空,说明是批量设置限制类型
|