|
@@ -64,10 +64,16 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
import java.io.File;
|
|
|
-import java.util.*;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.Map.Entry;
|
|
|
+import java.util.Optional;
|
|
|
+import java.util.Set;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -873,7 +879,7 @@ public class ExamServiceImpl implements ExamService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public boolean getIpLimited(HttpServletRequest request, Long examId, User accessUser) {
|
|
|
+ public boolean getIpLimited(String realIp, Long examId, User accessUser) {
|
|
|
//是否开启Ip限制
|
|
|
ExamPropertyCacheBean ipLimitProperty = CacheHelper.getExamProperty(examId, "IP_LIMIT");
|
|
|
boolean ipLimited = ipLimitProperty!=null && StringUtil.isTrue(ipLimitProperty.getValue());
|
|
@@ -883,8 +889,6 @@ public class ExamServiceImpl implements ExamService {
|
|
|
DynamicEnum ipCenterLimit = manager.getByName("IP_CENTER_LIMIT");
|
|
|
|
|
|
if (ipLimited) {
|
|
|
- String realIp = getIp(request);
|
|
|
- realIp = realIp.trim();
|
|
|
//整体控制
|
|
|
Integer totalLimit = getExamLimitProperty(examId, ipTotalLimit.getId(), 0);
|
|
|
if (totalLimit == 1) {
|
|
@@ -931,20 +935,6 @@ public class ExamServiceImpl implements ExamService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- 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不为空,说明是批量设置限制类型
|