feat: nlog, config hot-reload, and concurrency fixes

This commit is contained in:
xboard
2026-03-24 23:12:55 +08:00
parent 191e58b9ee
commit 7e3ad7cb23
22 changed files with 572 additions and 281 deletions
+7 -9
View File
@@ -203,17 +203,15 @@ func (t *Tracker) RestoreAliveIPs(data map[int][]string) {
if ips == nil {
ips = make([]string, 0, len(ipList))
}
// Use map for O(n) dedup instead of O(n²) linear search
existMap := make(map[string]struct{}, len(ips)+len(ipList))
for _, existing := range ips {
existMap[existing] = struct{}{}
}
for _, ip := range ipList {
// Dedup check
found := false
for _, existing := range ips {
if existing == ip {
found = true
break
}
}
if !found {
if _, exists := existMap[ip]; !exists {
ips = append(ips, ip)
existMap[ip] = struct{}{}
}
}
t.aliveIPsBuf[uid] = ips