zj
2025-03-07 5be80b796dd5885604aeab891e410b994b1d4dbe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package project.ddos.utils;
 
import java.util.Date;
 
import org.springframework.beans.factory.InitializingBean;
 
import kernel.util.TimeWindow;
 
public class LocklistIpSerivceTimeWindow implements InitializingBean {
    
    private TimeWindow timeWindow = new TimeWindow();
 
    public void afterPropertiesSet() throws Exception {
        /**
         * 24小时
         */
        this.timeWindow.setTimeSize(60 * 60 * 24);
        this.timeWindow.start();
    }
 
    public String getLockIp(String key) {
        Object authcode = this.timeWindow.findObject(key);
        if (authcode != null) {
            return String.valueOf(authcode.toString());
        }
        return null;
    }
 
    public void putLockIp(String key, String ip) {
        this.timeWindow.add(key, ip);
    }
 
    public void putLockIp(String key, String ip, Date date) {
        this.timeWindow.add(key, ip, date);
    }
 
    public void delLockIp(String key) {
        this.timeWindow.remove(key);
    }
 
}