75 lines
1.8 KiB
Go
75 lines
1.8 KiB
Go
// Package dto 定义服务器安全日志模块的服务边界对象(入参/出参)。
|
|
package dto
|
|
|
|
// SecurityLogFilter 安全日志查询筛选条件。
|
|
type SecurityLogFilter struct {
|
|
Page int // 页码,从 1 开始
|
|
Size int // 每页大小
|
|
SrcIp string // 来源 IP
|
|
EventType string // 事件类型(空=全部)
|
|
DestPort int // 目标端口(0=全部)
|
|
DateFrom string // 起始时间 YYYY-MM-DD HH:MM:SS
|
|
DateTo string // 结束时间 YYYY-MM-DD HH:MM:SS
|
|
}
|
|
|
|
// SecurityLogInput 上报入库的日志项。
|
|
type SecurityLogInput struct {
|
|
LogTime string // 事件发生时间 YYYY-MM-DD HH:MM:SS
|
|
SrcIp string // 来源 IP
|
|
SrcPort int // 来源端口
|
|
DestPort int // 目标端口
|
|
EventType string // 事件类型
|
|
Detail string // 日志详情
|
|
}
|
|
|
|
// SecurityLogVO 日志出参视图。
|
|
type SecurityLogVO struct {
|
|
Id uint64
|
|
LogTime string
|
|
SrcIp string
|
|
SrcPort int
|
|
DestPort int
|
|
EventType string
|
|
EventName string // 派生:事件中文名
|
|
Detail string
|
|
CreatedAt string
|
|
}
|
|
|
|
// SecurityStats 统计出参。
|
|
type SecurityStats struct {
|
|
Total int
|
|
Failed int
|
|
Banned int
|
|
Accepted int
|
|
TopIps []SecurityTopIp
|
|
ByType []SecurityByType
|
|
}
|
|
|
|
// SecurityTopIp TOP 攻击源。
|
|
type SecurityTopIp struct {
|
|
SrcIp string `json:"srcIp"`
|
|
Count int `json:"count"`
|
|
}
|
|
|
|
// SecurityByType 按类型分布。
|
|
type SecurityByType struct {
|
|
EventType string `json:"eventType"`
|
|
EventName string `json:"eventName"`
|
|
Count int `json:"count"`
|
|
}
|
|
|
|
// SecurityEventName 事件类型中文名。
|
|
func SecurityEventName(t string) string {
|
|
switch t {
|
|
case "failed_ssh":
|
|
return "SSH爆破尝试"
|
|
case "accepted_ssh":
|
|
return "SSH成功登录"
|
|
case "banned":
|
|
return "fail2ban封禁"
|
|
case "unbanned":
|
|
return "fail2ban解封"
|
|
}
|
|
return t
|
|
}
|