30 lines
1.4 KiB
Go
30 lines
1.4 KiB
Go
package models
|
||
|
||
import "time"
|
||
|
||
// TrapShield 表示一条针对 SNMP Trap 的“屏蔽/防护”规则。
|
||
type TrapShield struct {
|
||
// 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;not null" json:"name"`
|
||
// Enabled 表示该规则是否启用。
|
||
Enabled bool `gorm:"not null;default:true" json:"enabled"`
|
||
// SourceIPCIDR 表示规则适用的源 IP 网段(CIDR)。
|
||
SourceIPCIDR string `gorm:"column:source_ip_cidr;size:64;not null;default:''" json:"source_ip_cidr"`
|
||
// OIDPrefixes 表示可匹配的 Trap OID 前缀;多个前缀之间为“或”关系。
|
||
OIDPrefixes []string `gorm:"column:oid_prefixes;type:jsonb;serializer:json;not null;default:'[]'" json:"oid_prefixes"`
|
||
// InterfaceHint 关联提示信息(例如接口/线路标识),用于定位设备来源。
|
||
InterfaceHint string `gorm:"size:256;not null;default:''" json:"interface_hint"`
|
||
// TimeWindowsJSON 以 JSON 文本形式描述规则生效时间窗口。
|
||
TimeWindowsJSON string `gorm:"type:text;not null;default:''" json:"time_windows_json"`
|
||
}
|
||
|
||
func (TrapShield) TableName() string {
|
||
return "logs_trap_shields"
|
||
}
|