mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
3.0.0
This commit is contained in:
@@ -61,27 +61,23 @@ public class DefaultLimitConfigManager implements LimitConfigManager {
|
||||
*/
|
||||
protected Set<String> buildKeys(ConfigLimitDto configLimitDto) {
|
||||
Set<String> keys = new HashSet<>();
|
||||
Set<String> baseKeys = new HashSet<>();
|
||||
String routeId = Optional.ofNullable(configLimitDto.getRouteId()).orElse("");
|
||||
String appKey = Optional.ofNullable(configLimitDto.getAppKey()).orElse("");
|
||||
String limitIp = Optional.ofNullable(configLimitDto.getLimitIp()).orElse("").replaceAll("\\s", "");
|
||||
|
||||
|
||||
// 根据路由ID限流
|
||||
if (StringUtils.isNotBlank(routeId) && StringUtils.isBlank(appKey) && StringUtils.isBlank(limitIp)) {
|
||||
keys.add(routeId);
|
||||
baseKeys.add(routeId);
|
||||
}
|
||||
// 根据appKey限流
|
||||
if (StringUtils.isBlank(routeId) && StringUtils.isNotBlank(appKey) && StringUtils.isBlank(limitIp)) {
|
||||
keys.add(appKey);
|
||||
baseKeys.add(appKey);
|
||||
}
|
||||
// 根据路由ID + appKey限流
|
||||
if (StringUtils.isNotBlank(routeId) && StringUtils.isNotBlank(appKey) && StringUtils.isBlank(limitIp)) {
|
||||
keys.add(routeId.trim() + appKey.trim());
|
||||
baseKeys.add(routeId.trim() + appKey.trim());
|
||||
}
|
||||
Set<String> baseKeys = new HashSet<>(keys);
|
||||
// 根据ip限流
|
||||
if (StringUtils.isBlank(routeId) && StringUtils.isBlank(appKey) && StringUtils.isNotBlank(limitIp)) {
|
||||
String[] ips = limitIp.split("\\,|\\,");
|
||||
|
Reference in New Issue
Block a user