mirror of https://github.com/bjdgyc/anylink.git
修复无法自动解锁的Bug
This commit is contained in:
parent
c8cb9c163a
commit
1c6fc446c9
|
@ -55,12 +55,14 @@ iptables_nat = true
|
|||
|
||||
#防爆破全局开关
|
||||
anti_brute_force = true
|
||||
#全局IP白名单,多个用逗号分隔,支持单IP和CIDR范围
|
||||
ip_whitelist = "192.168.90.1,172.16.0.0/24"
|
||||
|
||||
#锁定时间最好不要超过单位时间
|
||||
#单位时间内最大尝试次数,0为关闭该功能
|
||||
max_ban_score = 5
|
||||
#设置单位时间(秒),超过则重置计数
|
||||
ban_reset_time = 10
|
||||
ban_reset_time = 600
|
||||
#超过最大尝试次数后的锁定时长(秒)
|
||||
lock_time = 300
|
||||
|
||||
|
|
|
@ -384,12 +384,20 @@ func (lm *LockManager) updateLockState(state *LockState, now time.Time, success
|
|||
state.LastAttempt = now
|
||||
}
|
||||
|
||||
// 超过时间窗口时重置锁定状态
|
||||
// 超过窗口时间和锁定时间时重置锁定状态
|
||||
func (lm *LockManager) resetLockStateIfExpired(state *LockState, now time.Time, resetTime int) {
|
||||
if state == nil || state.LastAttempt.IsZero() {
|
||||
return
|
||||
}
|
||||
|
||||
// 如果超过锁定时间,重置锁定状态
|
||||
if !state.LockTime.IsZero() && now.After(state.LockTime) {
|
||||
state.FailureCount = 0
|
||||
state.LockTime = time.Time{}
|
||||
return
|
||||
}
|
||||
|
||||
// 如果超过窗口时间,重置失败计数
|
||||
if now.Sub(state.LastAttempt) > time.Duration(resetTime)*time.Second {
|
||||
state.FailureCount = 0
|
||||
state.LockTime = time.Time{}
|
||||
|
|
Loading…
Reference in New Issue