fix : 黑名单拦截
This commit is contained in:
@@ -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为黑名单,无权访问"));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user