MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / cleanup

Method cleanup

internal/sessions/manager.go:409–436  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

407}
408
409func (m *Manager) cleanup() {
410 cutoff := time.Now().Add(-m.expiry)
411 m.mu.Lock()
412 defer m.mu.Unlock()
413 for id, sess := range m.sessions {
414 sess.mu.Lock()
415 pinned := sess.BridgePinned
416 expired := sess.LastActivity.Before(cutoff)
417 sess.mu.Unlock()
418 if pinned {
419 continue // bridge-registered sessions are never expired
420 }
421 if expired {
422 // Close all subscriber and observer channels before removing.
423 sess.mu.Lock()
424 for subID, ch := range sess.subscribers {
425 close(ch)
426 delete(sess.subscribers, subID)
427 }
428 for subID, ch := range sess.observers {
429 close(ch)
430 delete(sess.observers, subID)
431 }
432 sess.mu.Unlock()
433 delete(m.sessions, id)
434 }
435 }
436}
437
438func hashKey(apiKey string) string {
439 b := make([]byte, 16)

Callers 2

cleanupLoopMethod · 0.95
handleWebsocketMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected