Skip to content

Commit

Permalink
Don't drop Binding Requests in Controlled Agent
Browse files Browse the repository at this point in the history
A controlled Agent would discard incoming Binding Requests if it didn't
cause the pair to be selected. For UDP Candidate this would be
interpreted as packet loss. For TCP Candidates not responding with a
Binding Success could be interpreted as a failure.

Firefox's ICE Agent would disconnect TCP Candidates because of this
behavior.

Resolves to pion/webrtc#2125
Resolves to pion/webrtc#1356
See https://bugzilla.mozilla.org/show_bug.cgi?id=1756460
  • Loading branch information
Sean-Der committed Feb 21, 2022
1 parent fb4760c commit 4bb5d2c
Showing 1 changed file with 10 additions and 23 deletions.
33 changes: 10 additions & 23 deletions selection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 4bb5d2c

Please sign in to comment.