This commit is contained in:
zxr
2026-03-30 18:03:40 +08:00
parent 279021bf86
commit c152a9e573
6 changed files with 474 additions and 51 deletions

View File

@@ -2,16 +2,26 @@ package models
import "time"
// TrapShield 表示一条针对 SNMP Trap 的“屏蔽/防护”规则。
type TrapShield struct {
ID uint `gorm:"primaryKey" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Name string `gorm:"size:256" json:"name"`
Enabled bool `gorm:"default:true" json:"enabled"`
SourceIPCIDR string `gorm:"size:64" json:"source_ip_cidr"`
OIDPrefix string `gorm:"size:512" json:"oid_prefix"`
InterfaceHint string `gorm:"size:256" json:"interface_hint"`
TimeWindowsJSON string `gorm:"type:text" json:"time_windows_json"`
// ID 是数据库主键。
ID uint `gorm:"primaryKey" json:"id"`
// CreatedAt 记录创建时间GORM 自动维护)。
CreatedAt time.Time `json:"created_at"`
// UpdatedAt 记录更新时间GORM 自动维护)。
UpdatedAt time.Time `json:"updated_at"`
// Name 规则名称,用于展示/标识。
Name string `gorm:"size:256" json:"name"`
// Enabled 表示该规则是否启用。
Enabled bool `gorm:"default:true" json:"enabled"`
// SourceIPCIDR 表示规则适用的源 IP 网段CIDR
SourceIPCIDR string `gorm:"size:64" json:"source_ip_cidr"`
// OIDPrefix 表示匹配的 OID 前缀。
OIDPrefix string `gorm:"size:512" json:"oid_prefix"`
// InterfaceHint 关联提示信息(例如接口/线路标识),用于定位设备来源。
InterfaceHint string `gorm:"size:256" json:"interface_hint"`
// TimeWindowsJSON 以 JSON 文本形式描述规则生效时间窗口。
TimeWindowsJSON string `gorm:"type:text" json:"time_windows_json"`
}
func (TrapShield) TableName() string {