wangwei 7 năm trước cách đây
mục cha
commit
dc6d3f0684

+ 13 - 8
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/ExamController.java

@@ -453,6 +453,9 @@ public class ExamController extends ControllerSupport {
 		}
 
 		String realIp = request.getHeader("x-forwarded-for");
+		if (StringUtils.isBlank(realIp)) {
+			realIp = request.getHeader("x-real-ip");
+		}
 		if (StringUtils.isBlank(realIp)) {
 			throw new StatusException("E-001010", "网络受限");
 		}
@@ -460,15 +463,17 @@ public class ExamController extends ControllerSupport {
 
 		String ipAddresses = exam.getIpAddresses();
 
-		String[] arr = StringUtils.split(ipAddresses, ';');
-
 		boolean limited = true;
-		for (String cur : arr) {
-			String ip = StringUtils.replace(cur.trim(), ".", "\\.");
-			ip = StringUtils.replace(cur, "*", "\\w+");
-			if (realIp.matches(ip)) {
-				limited = false;
-				break;
+		if (StringUtils.isNotBlank(ipAddresses)) {
+			String[] arr = StringUtils.split(ipAddresses, ';');
+
+			for (String cur : arr) {
+				String ip = StringUtils.replace(cur.trim(), ".", "\\.");
+				ip = StringUtils.replace(cur, "*", "\\w+");
+				if (realIp.matches(ip)) {
+					limited = false;
+					break;
+				}
 			}
 		}