65 lines
1.7 KiB
Go
65 lines
1.7 KiB
Go
package storage
|
|
|
|
import "time"
|
|
|
|
type Alert struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
Type string `gorm:"index" json:"type"`
|
|
Severity string `gorm:"index" json:"severity"`
|
|
SrcIP string `gorm:"index" json:"src_ip"`
|
|
DstIP string `json:"dst_ip"`
|
|
SrcPort uint16 `json:"src_port"`
|
|
DstPort uint16 `json:"dst_port"`
|
|
Protocol string `json:"protocol"`
|
|
Description string `json:"description"`
|
|
Count int `json:"count"`
|
|
}
|
|
|
|
type PacketStat struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
Protocol string `json:"protocol"`
|
|
SrcIP string `json:"src_ip"`
|
|
DstIP string `json:"dst_ip"`
|
|
Bytes int64 `json:"bytes"`
|
|
}
|
|
|
|
type CaptureSession struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
EndedAt *time.Time `json:"ended_at"`
|
|
Source string `json:"source"`
|
|
Mode string `json:"mode"`
|
|
Status string `json:"status"`
|
|
TotalPkts int64 `json:"total_pkts"`
|
|
TotalBytes int64 `json:"total_bytes"`
|
|
}
|
|
|
|
// AlertFilter используется для фильтрации алертов в запросах
|
|
type AlertFilter struct {
|
|
Type string
|
|
Severity string
|
|
SrcIP string
|
|
DateFrom *time.Time
|
|
DateTo *time.Time
|
|
Page int
|
|
PageSize int
|
|
}
|
|
|
|
// SeverityOrder возвращает числовой приоритет для сортировки
|
|
func SeverityOrder(s string) int {
|
|
switch s {
|
|
case "critical":
|
|
return 4
|
|
case "high":
|
|
return 3
|
|
case "medium":
|
|
return 2
|
|
case "low":
|
|
return 1
|
|
default:
|
|
return 0
|
|
}
|
|
}
|