fix : 黑名单拦截

This commit is contained in:
clay
2024-03-07 15:12:29 +08:00
parent c396a58076
commit 4751732659

View File

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