新增:安全告警邮件展示来源 IP 网络归属(CDN/云厂商/WAF)
- 新增 internal/security/ipinfo:基于 projectdiscovery/cdncheck v1.3.0 (离线指纹、零外部请求)识别来源 IP 归属,识别失败折叠为展示标签, 不中断告警链路 - autoban 告警回调注入归属识别;告警邮件新增「网络归属」行, 命中 CDN/代理网络时提示「封禁可能无法拦截真实来源」 - 新增邮件模板渲染回归测试 internal/mail/mail_alert_test.go - dev/s3stub:webp(cgo) 本地类型检查桩,替换 s3.go 做全模块编译验证, 生产 Linux 构建不受影响;dev/overlay.json 指向该桩 - go mod tidy 顺带升级共享依赖(lipgloss/xid/testify 等), 全模块类型检查与相关包测试通过
This commit is contained in:
@@ -31,6 +31,7 @@ import (
|
||||
"github.com/tamakyi/TamaBox/internal/mail"
|
||||
"github.com/tamakyi/TamaBox/internal/route/chat" // 私聊路由
|
||||
"github.com/tamakyi/TamaBox/internal/security/autoban"
|
||||
"github.com/tamakyi/TamaBox/internal/security/ipinfo"
|
||||
"github.com/tamakyi/TamaBox/internal/shared"
|
||||
templatepkg "github.com/tamakyi/TamaBox/internal/template"
|
||||
"github.com/tamakyi/TamaBox/route"
|
||||
@@ -90,7 +91,12 @@ func New() *flamego.Flame {
|
||||
Window: time.Duration(conf.Security.BanWindowSeconds) * time.Second,
|
||||
Duration: time.Duration(conf.Security.BanDurationMinutes) * time.Minute,
|
||||
AlertEmail: conf.Security.SecurityAlertEmail,
|
||||
SendAlert: mail.SendSecurityAlertMail,
|
||||
// 告警发送前先离线识别来源 IP 的网络归属(CDN/云厂商/WAF,零外部请求),
|
||||
// 识别失败不影响告警发送(ipinfo.Lookup 内部已折叠错误)。
|
||||
SendAlert: func(ip string, paths []string, durationMinutes int) error {
|
||||
provider, proxied := ipinfo.Lookup(ip)
|
||||
return mail.SendSecurityAlertMail(ip, provider, proxied, paths, durationMinutes)
|
||||
},
|
||||
})
|
||||
// 需要输出详细日志时配置如下
|
||||
// if conf.App.Production {
|
||||
|
||||
Reference in New Issue
Block a user