mirror of
https://github.com/nezhahq/nezha.git
synced 2025-01-22 12:48:14 -05:00
parent
872002d938
commit
0648f61e9c
10
model/waf.go
10
model/waf.go
@ -43,10 +43,12 @@ func CheckIP(db *gorm.DB, ip string) error {
|
||||
return err
|
||||
}
|
||||
var w WAF
|
||||
if err := db.First(&w, "ip = ?", ipBinary).Error; err != nil {
|
||||
if err != gorm.ErrRecordNotFound {
|
||||
return err
|
||||
}
|
||||
result := db.Limit(1).Find(&w, "ip = ?", ipBinary)
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
if result.RowsAffected == 0 { // 检查是否未找到记录
|
||||
return nil
|
||||
}
|
||||
now := time.Now().Unix()
|
||||
if powAdd(w.Count, 4, w.LastBlockTimestamp) > uint64(now) {
|
||||
|
Loading…
Reference in New Issue
Block a user