fix : 黑名单拦截

This commit is contained in:
clay
2024-03-07 15:15:59 +08:00
parent 4751732659
commit c86f078b3d

View File

@@ -43,10 +43,9 @@ public class RequestGlobalFilter implements GlobalFilter, Ordered {
String remoteAddress = IpUtils.getIP(request);
log.info("Method:{{}} Host:{{}} 远程ip:{{}} Path:{{}} Query:{{}}", request.getMethod().name(), request.getURI().getHost(), remoteAddress, request.getURI().getPath(), request.getQueryParams());
Boolean flag = redisTemplate.opsForSet().isMember(IpBackUtils.BLACK_LIST_IP, remoteAddress);
log.info("flag: {} (flag != null) :{} (flag != null && flag) :{}", flag, (flag != null), (flag != null && flag))
;
// log.info("flag: {} (flag != null) :{} (flag != null && flag) :{}", flag, (flag != null), (flag != null && flag));
if (flag != null && flag) {
return errorInfo(exchange, Result.error(HttpStatus.FORBIDDEN, "ip为黑名单,无权访问"));
return errorInfo(exchange, Result.error(HttpStatus.NETWORK_AUTHENTICATION_REQUIRED, "ip为黑名单,无权访问"));
}
return chain.filter(exchange);
}