From b46f6ca259039461f11fcc237d2efcd0df685904 Mon Sep 17 00:00:00 2001 From: Gabor Retvari Date: Mon, 18 Nov 2024 18:23:24 +0100 Subject: [PATCH] Minor code reorg to simplify adding a user quota handler --- internal/server/turn.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/internal/server/turn.go b/internal/server/turn.go index b3e972bc..5367b82d 100644 --- a/internal/server/turn.go +++ b/internal/server/turn.go @@ -115,6 +115,12 @@ func handleAllocateRequest(r Request, m *stun.Message) error { } } + // Parse realm and username (already checked in authenticateRequest) + realmAttr := &stun.Realm{} + _ = realmAttr.GetFrom(m) + usernameAttr := &stun.Username{} + _ = usernameAttr.GetFrom(m) + // 7. At any point, the server MAY choose to reject the request with a // 486 (Allocation Quota Reached) error if it feels the client is // trying to exceed some locally defined allocation quota. The @@ -127,11 +133,6 @@ func handleAllocateRequest(r Request, m *stun.Message) error { // client to a different server. The use of this error code and // attribute follow the specification in [RFC5389]. lifetimeDuration := allocationLifeTime(m) - // Already checked realm/username in authenticateRequest - realmAttr := &stun.Realm{} - _ = realmAttr.GetFrom(m) - usernameAttr := &stun.Username{} - _ = usernameAttr.GetFrom(m) a, err := r.AllocationManager.CreateAllocation( fiveTuple, r.Conn,