Skip to content

Commit

Permalink
Accept nil Candidate in AddRemoteCandidate
Browse files Browse the repository at this point in the history
Allow a user to pass a nil Candidate. We perform no actions off of this
currently. Until browsers implement end-of-candidates consistently it
isn't something we can do.

Relates to pion/webrtc#1212 and #271
  • Loading branch information
scorpionknifes authored and Sean-Der committed Dec 9, 2020
1 parent 5e5f171 commit 7c89762
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,11 @@ func (a *Agent) checkKeepalive() {

// AddRemoteCandidate adds a new remote candidate
func (a *Agent) AddRemoteCandidate(c Candidate) error {
// canot check for network yet because it might not be applied
if c == nil {
return nil
}

// cannot check for network yet because it might not be applied
// when mDNS hostame is used.
if c.TCPType() == TCPTypeActive {
// TCP Candidates with tcptype active will probe server passive ones, so
Expand Down
8 changes: 8 additions & 0 deletions agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1686,3 +1686,11 @@ func TestLiteLifecycle(t *testing.T) {
<-bFailed
assert.NoError(t, bAgent.Close())
}

func TestNilCandidate(t *testing.T) {
a, err := NewAgent(&AgentConfig{})
assert.NoError(t, err)

assert.NoError(t, a.AddRemoteCandidate(nil))
assert.NoError(t, a.Close())
}

0 comments on commit 7c89762

Please sign in to comment.