|
@@ -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;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|