platform: modularize api/gui, add docs-tests-web foundation, and refresh root config
This commit is contained in:
44
selective-vpn-api/app/traffic_audit_duplicates.go
Normal file
44
selective-vpn-api/app/traffic_audit_duplicates.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func findProfileDuplicates(profiles []TrafficAppProfile) []string {
|
||||
return collectTargetKeyDuplicates(func(add func(target, key string)) {
|
||||
for _, p := range profiles {
|
||||
add(p.Target, p.AppKey)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func findMarkDuplicates(items []appMarkItem) []string {
|
||||
return collectTargetKeyDuplicates(func(add func(target, key string)) {
|
||||
for _, it := range items {
|
||||
add(it.Target, it.AppKey)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func collectTargetKeyDuplicates(feed func(add func(target, key string))) []string {
|
||||
seen := map[string]int{}
|
||||
feed(func(target, key string) {
|
||||
tgt := strings.ToLower(strings.TrimSpace(target))
|
||||
k := strings.TrimSpace(key)
|
||||
if tgt == "" || k == "" {
|
||||
return
|
||||
}
|
||||
seen[tgt+"|"+k]++
|
||||
})
|
||||
|
||||
var out []string
|
||||
for k, n := range seen {
|
||||
if n > 1 {
|
||||
out = append(out, fmt.Sprintf("%s x%d", k, n))
|
||||
}
|
||||
}
|
||||
sort.Strings(out)
|
||||
return out
|
||||
}
|
||||
Reference in New Issue
Block a user