ip 请求次数限制16
This commit is contained in:
parent
5b39f50ba9
commit
0488c84143
|
|
@ -63,12 +63,19 @@ public class IpAccessCounter {
|
||||||
removeCount.set(0);
|
removeCount.set(0);
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
Set<String> removedIps = new HashSet<>();
|
Set<String> removedIps = new HashSet<>();
|
||||||
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);
|
accessTimes.removeIf(time -> currentTime - time > ONE_MINUTE);
|
||||||
if (accessTimes.isEmpty()) {
|
if (accessTimes.isEmpty()) {
|
||||||
removedIps.add(ip);
|
removedIps.add(entry.getKey());
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
// IP_ACCESS_TIMES.forEach((ip, accessTimes) -> {
|
||||||
|
// accessTimes.removeIf(time -> currentTime - time > ONE_MINUTE);
|
||||||
|
// if (accessTimes.isEmpty()) {
|
||||||
|
// removedIps.add(ip);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
removedIps.forEach(IP_ACCESS_TIMES::remove);
|
removedIps.forEach(IP_ACCESS_TIMES::remove);
|
||||||
|
|
||||||
Set<String> removedBlacklistIps = new HashSet<>();
|
Set<String> removedBlacklistIps = new HashSet<>();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue