Validate TURN config to guard against invalid values (#4742)

This commit is contained in:
Raja Subramanian
2026-08-11 20:34:49 +05:30
committed by GitHub
parent c4c356f6ca
commit 7167f91493
7 changed files with 344 additions and 37 deletions
+5 -2
View File
@@ -1096,11 +1096,14 @@ func (r *RoomManager) iceServersForParticipant(apiKey string, participant types.
var username, credential string
if s.Secret != "" {
// Generate dynamic credentials using TURN static auth secrets
// Generate dynamic credentials using TURN static auth secrets.
// 0 means use the default; clamp the rest so a negative or overflowing TTL
// cannot produce a wrong-lifetime credential.
ttl := s.TTL
if ttl == 0 {
ttl = 14400 // Default 4 hours
ttl = config.DefaultExternalTURNTTLSeconds
}
ttl, _ = config.ClampTURNTTLSeconds(ttl)
expiry := time.Now().Add(time.Duration(ttl) * time.Second).Unix()
participantID := string(participant.ID())