EndpointActivity returns endpoint IP -> last seen unix timestamp for provided keys. If multiple keys share endpoint IP, the newest timestamp wins.
(keys []string)
| 234 | // EndpointActivity returns endpoint IP -> last seen unix timestamp for provided keys. |
| 235 | // If multiple keys share endpoint IP, the newest timestamp wins. |
| 236 | func (st *Tracker) EndpointActivity(keys []string) map[string]int64 { |
| 237 | st.mu.RLock() |
| 238 | defer st.mu.RUnlock() |
| 239 | |
| 240 | var result map[string]int64 |
| 241 | for _, key := range keys { |
| 242 | entry, exists := st.stats[key] |
| 243 | if !exists || entry.EndpointIP == "" || entry.LastActiveTime.IsZero() { |
| 244 | continue |
| 245 | } |
| 246 | |
| 247 | ts := entry.LastActiveTime.Unix() |
| 248 | if result == nil { |
| 249 | result = make(map[string]int64) |
| 250 | } |
| 251 | |
| 252 | if prev, ok := result[entry.EndpointIP]; !ok || ts > prev { |
| 253 | result[entry.EndpointIP] = ts |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | return result |
| 258 | } |
| 259 | |
| 260 | // RemoveStats marks a peer as deleted but keeps counters until a reset reports them. |
| 261 | func (st *Tracker) RemoveStats(publicKey string) { |
no outgoing calls