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

Fix AddRemoteCandidate to accept nil candidate #315

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 6 additions & 1 deletion agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,12 @@ 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
// accept nil candidate. aka end-of-candidates will not fail
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
13 changes: 13 additions & 0 deletions agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1686,3 +1686,16 @@ func TestLiteLifecycle(t *testing.T) {
<-bFailed
assert.NoError(t, bAgent.Close())
}

func TestNilCandidate(t *testing.T) {
var config AgentConfig
a, err := NewAgent(&config)
if err != nil {
t.Fatalf("Error constructing ice.Agent: %v", err)
}

err = a.AddRemoteCandidate(nil)
assert.NoError(t, err)

assert.NoError(t, a.Close())
}
Binary file added debug.test
Binary file not shown.