From c82f28d6cd1cd945fc17c1fc9e08064a9b83e3eb Mon Sep 17 00:00:00 2001 From: Raja Subramanian Date: Mon, 26 Oct 2026 17:30:10 +0530 Subject: [PATCH] service: export CheckConnectLimits (#5067) Servers that embed pkg/service and run their own join paths need the same join limit check. Rename checkConnectLimits to CheckConnectLimits. No behavior change. Co-authored-by: Claude Opus 5.5 --- pkg/service/roommanager.go | 2 +- pkg/service/utils.go | 7 ++++--- pkg/service/whipservice.go | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/service/roommanager.go b/pkg/service/roommanager.go index 95bd515df..f36829f36 100644 --- a/pkg/service/roommanager.go +++ b/pkg/service/roommanager.go @@ -297,7 +297,7 @@ func (r *RoomManager) StartSession( sessionStartTime := time.Now() if pi.Identity != "" && pi.Grants != nil { - if err := checkConnectLimits(r.config.Limit, string(pi.Identity), livekit.RoomName(pi.CreateRoom.GetName()), pi.Grants); err != nil { + if err := CheckConnectLimits(r.config.Limit, string(pi.Identity), livekit.RoomName(pi.CreateRoom.GetName()), pi.Grants); err != nil { return err } } diff --git a/pkg/service/utils.go b/pkg/service/utils.go index e4a22ba8a..3ee3a224d 100644 --- a/pkg/service/utils.go +++ b/pkg/service/utils.go @@ -419,7 +419,7 @@ func ValidateConnectRequest( } // after the publish suffix, so the identity checked is the one StartSession sees - if err := checkConnectLimits(limitConfig, claims.Identity, res.roomName, claims); err != nil { + if err := CheckConnectLimits(limitConfig, claims.Identity, res.roomName, claims); err != nil { return res, http.StatusBadRequest, err } @@ -454,10 +454,11 @@ func ValidateConnectRequest( return res, http.StatusOK, nil } -// checkConnectLimits checks a join's identity, room name, participant name, metadata and +// CheckConnectLimits checks a join's identity, room name, participant name, metadata and // attributes against the configured limits. Every join path runs it: the signal connection, // WHIP, and StartSession on the RTC node, which does not trust the caller's validation. -func checkConnectLimits(limitConfig config.LimitConfig, identity string, roomName livekit.RoomName, grants *auth.ClaimGrants) error { +// It is exported for servers that embed this package and run their own join paths. +func CheckConnectLimits(limitConfig config.LimitConfig, identity string, roomName livekit.RoomName, grants *auth.ClaimGrants) error { if !limitConfig.CheckParticipantIdentityLength(identity) { return fmt.Errorf("%w: max length %d", ErrParticipantIdentityExceedsLimits, limitConfig.MaxParticipantIdentityLength) } diff --git a/pkg/service/whipservice.go b/pkg/service/whipservice.go index 48ee38466..d380ed226 100644 --- a/pkg/service/whipservice.go +++ b/pkg/service/whipservice.go @@ -135,7 +135,7 @@ func (s *WHIPService) validateCreate(w http.ResponseWriter, r *http.Request) (*c return nil, http.StatusBadRequest, ErrIdentityEmpty } - if err := checkConnectLimits(s.config.Limit, claims.Identity, roomName, claims); err != nil { + if err := CheckConnectLimits(s.config.Limit, claims.Identity, roomName, claims); err != nil { return nil, http.StatusBadRequest, err }