This commit is contained in:
Mrx
2026-03-20 13:24:45 +08:00
parent 3779a7d66d
commit 521bfeb4ef
15 changed files with 530 additions and 40 deletions

View File

@@ -0,0 +1,21 @@
package entities
import "time"
// SuspiciousIPRecord 可疑IP请求记录
type SuspiciousIPRecord struct {
ID uint64 `gorm:"primaryKey;autoIncrement" json:"id"`
IP string `gorm:"type:varchar(64);not null;index:idx_ip_created,priority:1" json:"ip"`
Path string `gorm:"type:varchar(255);not null;index:idx_path_created,priority:1" json:"path"`
Method string `gorm:"type:varchar(16);not null;default:GET" json:"method"`
RequestCount int `gorm:"not null;default:1" json:"request_count"`
WindowSeconds int `gorm:"not null;default:10" json:"window_seconds"`
TriggerReason string `gorm:"type:varchar(64);not null;default:rate_limit" json:"trigger_reason"`
UserAgent string `gorm:"type:varchar(512);not null;default:''" json:"user_agent"`
CreatedAt time.Time `gorm:"autoCreateTime;index:idx_ip_created,priority:2;index:idx_path_created,priority:2;index:idx_created" json:"created_at"`
}
// TableName 指定表名
func (SuspiciousIPRecord) TableName() string {
return "suspicious_ip_records"
}