MCPcopy Create free account
hub / github.com/dan-v/lambda-nat-proxy / GenerateSessionID

Function GenerateSessionID

pkg/shared/utils.go:11–20  ·  view source on GitHub ↗

GenerateSessionID creates a unique session identifier

()

Source from the content-addressed store, hash-verified

9
10// GenerateSessionID creates a unique session identifier
11func GenerateSessionID() string {
12 bytes := make([]byte, 8)
13 if _, err := rand.Read(bytes); err != nil {
14 // This should never happen with crypto/rand, but handle gracefully
15 // Fall back to a timestamp-based ID if crypto/rand fails
16 LogError("Failed to generate cryptographic session ID, falling back to timestamp", err)
17 return GenerateTimestampID()
18 }
19 return hex.EncodeToString(bytes)
20}
21
22// GenerateTimestampID creates a session ID based on current time as fallback
23func GenerateTimestampID() string {

Callers 2

LaunchMethod · 0.92
TestGenerateSessionIDFunction · 0.92

Calls 2

LogErrorFunction · 0.85
GenerateTimestampIDFunction · 0.85

Tested by 1

TestGenerateSessionIDFunction · 0.74