|
@@ -452,7 +452,7 @@ func (s *wafFormatterService) WashDelIps(ctx context.Context, ips []string) ([]s
|
|
|
|
|
|
// 2. 汇总所有计数结果
|
|
|
totalCountMap := make(map[string]int)
|
|
|
- // 将多个 for 循环合并到一个函数中,可以显得更整洁(可选)
|
|
|
+ // 将多个 for 循环合并到一个函数中
|
|
|
accumulateCounts := func(counts []v1.IpCountResult) {
|
|
|
for _, result := range counts {
|
|
|
totalCountMap[result.Ip] += result.Count
|
|
@@ -462,10 +462,10 @@ func (s *wafFormatterService) WashDelIps(ctx context.Context, ips []string) ([]s
|
|
|
accumulateCounts(tcpIpCounts)
|
|
|
accumulateCounts(webIpCounts)
|
|
|
|
|
|
- // 3. 筛选出总引用数小于 2 的 IP
|
|
|
+ // 3. 筛选出总引用数等于 1 的 IP
|
|
|
var ipsToDelist []string
|
|
|
for _, ip := range ips {
|
|
|
- if totalCountMap[ip] < 2 {
|
|
|
+ if totalCountMap[ip] == 1 {
|
|
|
ipsToDelist = append(ipsToDelist, ip)
|
|
|
}
|
|
|
}
|