ip 请求次数限制18
This commit is contained in:
parent
da9db2f8b1
commit
69cf777a8f
|
|
@ -63,22 +63,21 @@ public class IpAccessCounter {
|
|||
removeCount.set(0);
|
||||
long currentTime = System.currentTimeMillis();
|
||||
Set<String> removedIps = new HashSet<>();
|
||||
for (Map.Entry<String, List<Long>> entry : IP_ACCESS_TIMES.entrySet()) {
|
||||
List<Long> accessTimes = entry.getValue();
|
||||
if (accessTimes == null || accessTimes.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
accessTimes.removeIf(time -> currentTime - time > ONE_MINUTE);
|
||||
if (accessTimes.isEmpty()) {
|
||||
removedIps.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
// IP_ACCESS_TIMES.forEach((ip, accessTimes) -> {
|
||||
// for (Map.Entry<String, List<Long>> entry : IP_ACCESS_TIMES.entrySet()) {
|
||||
// List<Long> accessTimes = entry.getValue();
|
||||
// accessTimes.removeIf(time -> currentTime - time > ONE_MINUTE);
|
||||
// if (accessTimes.isEmpty()) {
|
||||
// removedIps.add(ip);
|
||||
// removedIps.add(entry.getKey());
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
IP_ACCESS_TIMES.forEach((ip, accessTimes) -> {
|
||||
if (accessTimes != null && !accessTimes.isEmpty()) {
|
||||
accessTimes.removeIf(time -> currentTime - time > ONE_MINUTE);
|
||||
if (accessTimes.isEmpty()) {
|
||||
removedIps.add(ip);
|
||||
}
|
||||
}
|
||||
});
|
||||
removedIps.forEach(IP_ACCESS_TIMES::remove);
|
||||
|
||||
Set<String> removedBlacklistIps = new HashSet<>();
|
||||
|
|
|
|||
Loading…
Reference in New Issue