|
|
@@ -73,14 +73,7 @@ public class AuthInterceptor implements HandlerInterceptor {
|
|
|
String uri = request.getRequestURI();
|
|
|
String ip = ReqUtils.getClientIp();
|
|
|
log.info("====================客户端请求信息:request uri: {}, IP: {}", uri, ip);
|
|
|
- boolean check = RedisOpsUtils.checkExist(ip);
|
|
|
- if (!check) {
|
|
|
- check = whiteListService.selIp(ip);
|
|
|
- if (check) {
|
|
|
- RedisOpsUtils.set(ip, ip);
|
|
|
- RedisOpsUtils.setWithExpire(ip, ip, RedisConst.WHITELIST_ALIVE_SECOND);
|
|
|
- }
|
|
|
- }
|
|
|
+ boolean check = checkIPStr(ip);
|
|
|
if(check) {
|
|
|
response.setStatus(HttpStatus.OK.value());
|
|
|
} else {
|
|
|
@@ -90,6 +83,27 @@ public class AuthInterceptor implements HandlerInterceptor {
|
|
|
return check;
|
|
|
}
|
|
|
|
|
|
+ private boolean checkIPStr(String ipStr) {
|
|
|
+ if(StringUtils.hasText(ipStr)) {
|
|
|
+ String[] ips = ipStr.split(",");
|
|
|
+ for(String ip : ips) {
|
|
|
+ ip = ip.trim();
|
|
|
+ boolean check = RedisOpsUtils.checkExist(ip);
|
|
|
+ if (!check) {
|
|
|
+ check = whiteListService.selIp(ip);
|
|
|
+ if (check) {
|
|
|
+ RedisOpsUtils.set(ip, ip);
|
|
|
+ RedisOpsUtils.setWithExpire(ip, ip, RedisConst.WHITELIST_ALIVE_SECOND);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
private boolean checkToken(HttpServletRequest request, HttpServletResponse response) {
|
|
|
String token = request.getHeader(PARAM_TOKEN);
|
|
|
if (!StringUtils.hasText(token)) {
|