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

prevent duplication of candidates with same remote ip:port #242

Merged
merged 1 commit into from
Jan 23, 2024
Merged
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
12 changes: 11 additions & 1 deletion src/RTPBundleTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,16 @@ void RTPBundleTransport::OnRead(const int fd, const uint8_t* data, const size_t

//Get candidate
ICERemoteCandidate* candidate = &itc->second;

//If the candidate already existed and belonged to a different transport,
//then the other side is sharing an endpoint for many transports, which
//prevents operation entirely.
if (candidate->GetUsername() != username)
{
//Log error and exit
Warning("-RTPBundleTransport:::Read() | candidate %s already used by another transport [username:%s,owner:%s]\n", remote.c_str(), username.c_str(), candidate->GetUsername().c_str());
return;
}

//Check if it is not already present
if (inserted)
Expand Down Expand Up @@ -770,7 +780,7 @@ int RTPBundleTransport::AddRemoteCandidate(const std::string& username,const cha
//assumption, but in case it ever happens, we print an error.
if (candidate->GetUsername() != username)
{
Error("-RTPBundleTransport::AddRemoteCandidate() | candidate %s already used by another transport [username:%s}\n", remote.c_str(), username.c_str());
Error("-RTPBundleTransport::AddRemoteCandidate() | candidate %s already used by another transport [username:%s,owner:%s]\n", remote.c_str(), username.c_str(), candidate->GetUsername().c_str());
return;
}

Expand Down
Loading