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

Method GetAndRefresh

sdk/cliproxy/auth/session_cache.go:60–81  ·  view source on GitHub ↗

GetAndRefresh retrieves the auth ID bound to a session and refreshes TTL on hit. This extends the binding lifetime for active sessions.

(sessionID string)

Source from the content-addressed store, hash-verified

58// GetAndRefresh retrieves the auth ID bound to a session and refreshes TTL on hit.
59// This extends the binding lifetime for active sessions.
60func (c *SessionCache) GetAndRefresh(sessionID string) (string, bool) {
61 if sessionID == "" {
62 return "", false
63 }
64 now := time.Now()
65 c.mu.Lock()
66 entry, ok := c.entries[sessionID]
67 if !ok {
68 c.mu.Unlock()
69 return "", false
70 }
71 if now.After(entry.expiresAt) {
72 delete(c.entries, sessionID)
73 c.mu.Unlock()
74 return "", false
75 }
76 // Refresh TTL on successful access
77 entry.expiresAt = now.Add(c.ttl)
78 c.entries[sessionID] = entry
79 c.mu.Unlock()
80 return entry.authID, true
81}
82
83// Set binds a session to an auth ID with TTL refresh.
84func (c *SessionCache) Set(sessionID, authID string) {

Callers 2

PickMethod · 0.80

Calls

no outgoing calls

Tested by 1