Skip to content

Commit

Permalink
Minor code reorg to simplify adding a user quota handler
Browse files Browse the repository at this point in the history
  • Loading branch information
rg0now committed Nov 18, 2024
1 parent dae4d0c commit b46f6ca
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions internal/server/turn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down

0 comments on commit b46f6ca

Please sign in to comment.