Skip to content

Commit

Permalink
make format
Browse files Browse the repository at this point in the history
  • Loading branch information
ibc committed Feb 15, 2024
1 parent 57c756c commit 3d1f3a1
Showing 1 changed file with 31 additions and 25 deletions.
56 changes: 31 additions & 25 deletions worker/src/RTC/IceServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// #define MS_LOG_DEV_LEVEL 3

#include "RTC/IceServer.hpp"
#include "Logger.hpp"
#include "DepLibUV.hpp"
#include "Logger.hpp"

namespace RTC
{
Expand Down Expand Up @@ -337,7 +337,9 @@ namespace RTC

case RTC::StunPacket::Authentication::BAD_MESSAGE:
{
MS_WARN_TAG(ice, "cannot check authentication in received STUN Binding Success Response, discarded");
MS_WARN_TAG(
ice,
"cannot check authentication in received STUN Binding Success Response, discarded");

return;
}
Expand Down Expand Up @@ -404,7 +406,7 @@ namespace RTC
return;
}

// TODO: Check if this a 403 response to our consent request and do stuff.
// TODO: Check if this a 403 response to our consent request and do stuff.
}

break;
Expand Down Expand Up @@ -534,7 +536,8 @@ namespace RTC
// Mark it as selected tuple.
auto isNewSelectedTuple = SetSelectedTuple(storedTuple);

if (isNewSelectedTuple) {
if (isNewSelectedTuple)
{
MayStartOrRestartConsentChecks();
}
}
Expand Down Expand Up @@ -721,7 +724,8 @@ namespace RTC
// Notify the listener.
this->listener->OnIceServerCompleted(this);

if (isNewSelectedTuple) {
if (isNewSelectedTuple)
{
MayStartOrRestartConsentChecks();
}
}
Expand Down Expand Up @@ -759,7 +763,8 @@ namespace RTC
this->remoteNomination = nomination;
}

if (isNewSelectedTuple) {
if (isNewSelectedTuple)
{
MayStartOrRestartConsentChecks();
}
}
Expand Down Expand Up @@ -894,7 +899,8 @@ namespace RTC
}

// Create the ICE consent checks timer if it doesn't exist.
if (!this->consentCheckTimer) {
if (!this->consentCheckTimer)
{
this->consentCheckTimer = new TimerHandle(this);
}

Expand All @@ -905,7 +911,8 @@ namespace RTC
{
MS_TRACE();

if (this->consentCheckTimer) {
if (this->consentCheckTimer)
{
this->consentCheckTimer->Stop();
}

Expand Down Expand Up @@ -957,11 +964,7 @@ namespace RTC
auto& sentContext = this->sentConsents.emplace_back(transactionId, DepLibUV::GetTimeMs());

auto* request = new StunPacket(
StunPacket::Class::REQUEST,
StunPacket::Method::BINDING,
sentContext.transactionId,
nullptr,
0);
StunPacket::Class::REQUEST, StunPacket::Method::BINDING, sentContext.transactionId, nullptr, 0);

const std::string username = this->remoteUsernameFragment + ":" + this->usernameFragment;

Expand All @@ -984,7 +987,9 @@ namespace RTC
if (timer == this->consentCheckTimer)
{
// State must be 'connected' or 'completed'.
MS_ASSERT(this->state == IceState::COMPLETED || this->state == IceState::CONNECTED, "ICE consent check timer fired but state is neither 'completed' nor 'connected'");
MS_ASSERT(
this->state == IceState::COMPLETED || this->state == IceState::CONNECTED,
"ICE consent check timer fired but state is neither 'completed' nor 'connected'");
// There should be a selected tuple.
MS_ASSERT(this->selectedTuple, "ICE consent check timer fired but there is not selected tuple");

Expand All @@ -1006,17 +1011,18 @@ namespace RTC

if (it == this->sentConsents.end())
{
// Send a new ICE consent request.
SendConsentRequest();

/*
* The interval between ICE consent requests is varied randomly over the
* range [0.8, 1.2] times the calculated interval to prevent
* synchronization of consent checks.
*/
const uint64_t interval = ConsentCheckIntervalMs + static_cast<float>(Utils::Crypto::GetRandomUInt(8, 12)) / 10;

this->consentCheckTimer->Start(interval);
// Send a new ICE consent request.
SendConsentRequest();

/*
* The interval between ICE consent requests is varied randomly over the
* range [0.8, 1.2] times the calculated interval to prevent
* synchronization of consent checks.
*/
const uint64_t interval =
ConsentCheckIntervalMs + static_cast<float>(Utils::Crypto::GetRandomUInt(8, 12)) / 10;

this->consentCheckTimer->Start(interval);
}
else
{
Expand Down

0 comments on commit 3d1f3a1

Please sign in to comment.