mirror of
https://github.com/yusing/godoxy.git
synced 2026-01-11 14:20:32 +01:00
refactor(acl): optimize slice allocation in logNotifyLoop
This commit is contained in:
@@ -216,18 +216,21 @@ func (c *Config) logNotifyLoop(parent task.Parent) {
|
||||
if total == 0 {
|
||||
continue
|
||||
}
|
||||
fieldsBody := make(notif.FieldsBody, 0, total)
|
||||
fieldsBody := make(notif.FieldsBody, total)
|
||||
i := 0
|
||||
for ip, count := range c.allowCounts {
|
||||
fieldsBody = append(fieldsBody, notif.LogField{
|
||||
fieldsBody[i] = notif.LogField{
|
||||
Name: ip,
|
||||
Value: fmt.Sprintf("allowed %d times", count),
|
||||
})
|
||||
}
|
||||
i++
|
||||
}
|
||||
for ip, count := range c.blockedCounts {
|
||||
fieldsBody = append(fieldsBody, notif.LogField{
|
||||
fieldsBody[i] = notif.LogField{
|
||||
Name: ip,
|
||||
Value: fmt.Sprintf("blocked %d times", count),
|
||||
})
|
||||
}
|
||||
i++
|
||||
}
|
||||
notif.Notify(¬if.LogMessage{
|
||||
Level: zerolog.InfoLevel,
|
||||
|
||||
Reference in New Issue
Block a user