feat: 新增 SMTP/IMAP/POP3 协议调用日志(含攻击分析筛选)

- 每个连接记录一条日志:协议、端口、来源 IP、用户名、成功/失败、
  失败原因(密码错误/IP封禁/中继被拒/发件人伪造/未认证发信等)、
  操作摘要、消息数与会话时长
- 管理后台新增「协议日志」页:按协议/状态/IP/用户名/时间筛选,
  今日与历史成功/失败统计卡片,分页查看,可手动清理
- 后台每 6 小时自动清理超出 protocol_log_keep_days(默认30天)
  的日志;新增 [web] protocol_log_keep_days 配置项
- 修复 POP3 认证既有 bug:handleUSER 丢弃邮箱域名导致 PASS 永远失败
- 新增 store 单测、SMTP/POP3 端到端测试与模板渲染测试
This commit is contained in:
2026-08-19 18:49:29 +08:00
parent 8ea4a623a9
commit 353bfa88f2
30 changed files with 1233 additions and 59 deletions
+15 -12
View File
@@ -8,23 +8,25 @@ import (
// Stores aggregates all store interfaces for convenient access.
type Stores struct {
Users UserStore
Mails MailStore
Domains DomainStore
Attachments AttachmentStore
Bans BanStore
Outbound OutboundStore
Users UserStore
Mails MailStore
Domains DomainStore
Attachments AttachmentStore
Bans BanStore
Outbound OutboundStore
ProtocolLogs ProtocolLogStore
}
// NewStores creates a new Stores instance with all GORM-backed implementations.
func NewStores(database *gorm.DB) *Stores {
return &Stores{
Users: newUserStore(database),
Mails: newMailStore(database),
Domains: newDomainStore(database),
Attachments: newAttachmentStore(database),
Bans: newBanStore(database),
Outbound: newOutboundStore(database),
Users: newUserStore(database),
Mails: newMailStore(database),
Domains: newDomainStore(database),
Attachments: newAttachmentStore(database),
Bans: newBanStore(database),
Outbound: newOutboundStore(database),
ProtocolLogs: newProtocolLogStore(database),
}
}
@@ -34,3 +36,4 @@ var _ = db.Domain{}
var _ = db.Message{}
var _ = db.Attachment{}
var _ = db.BanEntry{}
var _ = db.ProtocolLog{}