From 412a0616689f386b1f9cc10346d33d13c5c48168 Mon Sep 17 00:00:00 2001 From: tanghc Date: Fri, 9 Apr 2021 20:14:41 +0800 Subject: [PATCH 1/2] 4.4.0 --- .../gateway/filter/LimitFilter.java | 1 + .../manager/DefaultLimitConfigManager.java | 17 +++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/LimitFilter.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/LimitFilter.java index 3966c3c1..fb8d892b 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/LimitFilter.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/LimitFilter.java @@ -85,6 +85,7 @@ public class LimitFilter implements GlobalFilter, Ordered { appKey, routeId + appKey, + ip, ip + routeId, ip + appKey, ip + routeId + appKey, diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/DefaultLimitConfigManager.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/DefaultLimitConfigManager.java index 77bd78fc..bd4d42f4 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/DefaultLimitConfigManager.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/DefaultLimitConfigManager.java @@ -82,20 +82,25 @@ public class DefaultLimitConfigManager implements LimitConfigManager { if (StringUtils.isNotBlank(routeId) && StringUtils.isNotBlank(appKey) && StringUtils.isBlank(limitIp)) { keys.add(routeId.trim() + appKey.trim()); } - Set baseKeys = new HashSet<>(keys); // 根据ip限流 if (StringUtils.isBlank(routeId) && StringUtils.isBlank(appKey) && StringUtils.isNotBlank(limitIp)) { String[] ips = limitIp.split("\\,|\\,"); keys.addAll(Arrays.asList(ips)); } - // 根据ip+路由id限流 - // 根据ip+appKey限流 - // 根据ip+路由id+appKey限流 if (StringUtils.isNotBlank(limitIp)) { String[] ips = limitIp.split("\\,|\\,"); for (String ip : ips) { - for (String baseKey : baseKeys) { - keys.add(ip + baseKey); + // 根据ip+路由id限流 + if (StringUtils.isNotBlank(ip) && StringUtils.isNotBlank(routeId) && StringUtils.isBlank(appKey)) { + keys.add(routeId); + } + // 根据ip+appKey限流 + if (StringUtils.isNotBlank(ip) && StringUtils.isBlank(routeId) && StringUtils.isNotBlank(appKey)) { + keys.add(ip + appKey); + } + // 根据ip+路由id+appKey限流 + if (StringUtils.isNotBlank(ip) && StringUtils.isNotBlank(routeId) && StringUtils.isNotBlank(appKey)) { + keys.add(ip + routeId +appKey); } } } From c8fb583c7aad025c25ea926d35b20698d061a12a Mon Sep 17 00:00:00 2001 From: tanghc Date: Fri, 9 Apr 2021 20:17:17 +0800 Subject: [PATCH 2/2] 4.4.0 --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index a0a8dc4b..56f43429 100644 --- a/changelog.md +++ b/changelog.md @@ -6,6 +6,7 @@ - 优化异常处理 - 优化网关多实例数据库重复保存问题 +- 修复`IP`,`IP+路由ID`,`IP+APP_ID`限流不生效问题 ## 4.3.4