diff --git a/selection.go b/selection.go index 72484148..fba7f798 100644 --- a/selection.go +++ b/selection.go @@ -240,33 +240,20 @@ func (s *controlledSelector) HandleBindingRequest(m *stun.Message, local, remote p = s.agent.addPair(local, remote) } - if useCandidate { + if useCandidate && p.state == CandidatePairStateSucceeded { // https://tools.ietf.org/html/rfc8445#section-7.3.1.5 - if p.state == CandidatePairStateSucceeded { - // If the state of this pair is Succeeded, it means that the check - // previously sent by this pair produced a successful response and - // generated a valid pair (Section 7.2.5.3.2). The agent sets the - // nominated flag value of the valid pair to true. - if selectedPair := s.agent.getSelectedPair(); selectedPair == nil { - s.agent.setSelectedPair(p) - } - s.agent.sendBindingSuccess(m, local, remote) - } else { - // If the received Binding request triggered a new check to be - // enqueued in the triggered-check queue (Section 7.3.1.4), once the - // check is sent and if it generates a successful response, and - // generates a valid pair, the agent sets the nominated flag of the - // pair to true. If the request fails (Section 7.2.5.2), the agent - // MUST remove the candidate pair from the valid list, set the - // candidate pair state to Failed, and set the checklist state to - // Failed. - s.PingCandidate(local, remote) + // If the state of this pair is Succeeded, it means that the check + // previously sent by this pair produced a successful response and + // generated a valid pair (Section 7.2.5.3.2). The agent sets the + // nominated flag value of the valid pair to true. + if selectedPair := s.agent.getSelectedPair(); selectedPair == nil { + s.agent.setSelectedPair(p) } - } else { - s.agent.sendBindingSuccess(m, local, remote) - s.PingCandidate(local, remote) } + + s.agent.sendBindingSuccess(m, local, remote) + s.PingCandidate(local, remote) } type liteSelector struct {