Skip to content

Commit

Permalink
Update waf.go (#548)
Browse files Browse the repository at this point in the history
WAF查询IP是否被封禁导致控制台大量报错,换一个查询方式。
  • Loading branch information
yumusb authored Dec 4, 2024
1 parent 872002d commit 0648f61
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions model/waf.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 0648f61

Please sign in to comment.