Skip to content

Commit

Permalink
prevent duplication of candidates with same remote ip:port
Browse files Browse the repository at this point in the history
  • Loading branch information
murillo128 committed Jan 23, 2024
1 parent 41932a3 commit 191f784
Showing 1 changed file with 11 additions and 1 deletion.
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

0 comments on commit 191f784

Please sign in to comment.