Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't drop Binding Requests in Controlled Agent #426

Merged
merged 1 commit into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions candidatepair.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ func newCandidatePair(local, remote Candidate, controlling bool) *CandidatePair
// CandidatePair is a combination of a
// local and remote candidate
type CandidatePair struct {
iceRoleControlling bool
Remote Candidate
Local Candidate
bindingRequestCount uint16
state CandidatePairState
nominated bool
iceRoleControlling bool
Remote Candidate
Local Candidate
bindingRequestCount uint16
state CandidatePairState
nominated bool
nominateOnBindingSuccess bool
}

func (p *CandidatePair) String() string {
Expand Down
15 changes: 9 additions & 6 deletions selection.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,17 @@ func (s *controlledSelector) HandleSuccessResponse(m *stun.Message, local, remot

p.state = CandidatePairStateSucceeded
s.log.Tracef("Found valid candidate pair: %s", p)
if p.nominateOnBindingSuccess {
if selectedPair := s.agent.getSelectedPair(); selectedPair == nil {
s.agent.setSelectedPair(p)
}
}
}

func (s *controlledSelector) HandleBindingRequest(m *stun.Message, local, remote Candidate) {
useCandidate := m.Contains(stun.AttrUseCandidate)

p := s.agent.findPair(local, remote)

if p == nil {
p = s.agent.addPair(local, remote)
}
Expand All @@ -251,7 +255,6 @@ func (s *controlledSelector) HandleBindingRequest(m *stun.Message, local, remote
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
Expand All @@ -261,12 +264,12 @@ func (s *controlledSelector) HandleBindingRequest(m *stun.Message, local, remote
// 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)
p.nominateOnBindingSuccess = true
}
} 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