mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-25 10:18:59 +02: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 {
|
if total == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
fieldsBody := make(notif.FieldsBody, 0, total)
|
fieldsBody := make(notif.FieldsBody, total)
|
||||||
|
i := 0
|
||||||
for ip, count := range c.allowCounts {
|
for ip, count := range c.allowCounts {
|
||||||
fieldsBody = append(fieldsBody, notif.LogField{
|
fieldsBody[i] = notif.LogField{
|
||||||
Name: ip,
|
Name: ip,
|
||||||
Value: fmt.Sprintf("allowed %d times", count),
|
Value: fmt.Sprintf("allowed %d times", count),
|
||||||
})
|
}
|
||||||
|
i++
|
||||||
}
|
}
|
||||||
for ip, count := range c.blockedCounts {
|
for ip, count := range c.blockedCounts {
|
||||||
fieldsBody = append(fieldsBody, notif.LogField{
|
fieldsBody[i] = notif.LogField{
|
||||||
Name: ip,
|
Name: ip,
|
||||||
Value: fmt.Sprintf("blocked %d times", count),
|
Value: fmt.Sprintf("blocked %d times", count),
|
||||||
})
|
}
|
||||||
|
i++
|
||||||
}
|
}
|
||||||
notif.Notify(¬if.LogMessage{
|
notif.Notify(¬if.LogMessage{
|
||||||
Level: zerolog.InfoLevel,
|
Level: zerolog.InfoLevel,
|
||||||
|
|||||||
Reference in New Issue
Block a user