Skip to content

Commit

Permalink
cosmetic
Browse files Browse the repository at this point in the history
  • Loading branch information
ibc committed Feb 19, 2024
1 parent 06c0b8f commit 9e4eac9
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 48 deletions.
72 changes: 36 additions & 36 deletions worker/src/RTC/IceServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ namespace RTC

this->tuples.clear();

// Clear queue of ongoing sent ICE consent Requests.
// Clear queue of ongoing sent ICE consent request.
this->sentConsents.clear();

// Delete the ICE consent check timer.
Expand Down Expand Up @@ -281,14 +281,14 @@ namespace RTC
{
MS_TRACE();

MS_DEBUG_DEV("processing STUN Request");
MS_DEBUG_DEV("processing STUN request");

// Must be a Binding method.
if (request->GetMethod() != RTC::StunPacket::Method::BINDING)
{
MS_WARN_TAG(
ice,
"STUN Request with unknown method %#.3x => 400",
"STUN request with unknown method %#.3x => 400",
static_cast<unsigned int>(request->GetMethod()));

// Reply 400.
Expand All @@ -305,7 +305,7 @@ namespace RTC
// Must have FINGERPRINT attribute.
if (!request->HasFingerprint())
{
MS_WARN_TAG(ice, "STUN Binding Request without FINGERPRINT attribute => 400");
MS_WARN_TAG(ice, "STUN Binding request without FINGERPRINT attribute => 400");

// Reply 400.
RTC::StunPacket* response = request->CreateErrorResponse(400);
Expand All @@ -321,7 +321,7 @@ namespace RTC
// PRIORITY attribute is required.
if (request->GetPriority() == 0u)
{
MS_WARN_TAG(ice, "STUN Binding Request without PRIORITY attribute => 400");
MS_WARN_TAG(ice, "STUN Binding request without PRIORITY attribute => 400");

// Reply 400.
RTC::StunPacket* response = request->CreateErrorResponse(400);
Expand Down Expand Up @@ -373,7 +373,7 @@ namespace RTC
break;
}

MS_WARN_TAG(ice, "wrong authentication in STUN Binding Request => 401");
MS_WARN_TAG(ice, "wrong authentication in STUN Binding request => 401");

// Reply 401.
RTC::StunPacket* response = request->CreateErrorResponse(401);
Expand All @@ -388,7 +388,7 @@ namespace RTC

case RTC::StunPacket::Authentication::BAD_MESSAGE:
{
MS_WARN_TAG(ice, "cannot check authentication in STUN Binding Request => 400");
MS_WARN_TAG(ice, "cannot check authentication in STUN Binding request => 400");

// Reply 400.
RTC::StunPacket* response = request->CreateErrorResponse(400);
Expand All @@ -405,7 +405,7 @@ namespace RTC
// The remote peer must be ICE controlling.
if (request->GetIceControlled())
{
MS_WARN_TAG(ice, "peer indicates ICE-CONTROLLED in STUN Binding Request => 487");
MS_WARN_TAG(ice, "peer indicates ICE-CONTROLLED in STUN Binding request => 487");

// Reply 487 (Role Conflict).
RTC::StunPacket* response = request->CreateErrorResponse(487);
Expand All @@ -419,7 +419,7 @@ namespace RTC
}

MS_DEBUG_DEV(
"valid STUN Binding Request [priority:%" PRIu32 ", useCandidate:%s]",
"valid STUN Binding request [priority:%" PRIu32 ", useCandidate:%s]",
static_cast<uint32_t>(request->GetPriority()),
request->HasUseCandidate() ? "true" : "false");

Expand Down Expand Up @@ -460,50 +460,50 @@ namespace RTC
{
MS_TRACE();

MS_DEBUG_DEV("processing STUN Indication");
MS_DEBUG_DEV("processing STUN indication");

// Must be a Binding method.
if (indication->GetMethod() != RTC::StunPacket::Method::BINDING)
{
MS_WARN_TAG(
ice,
"STUN Indication with unknown method %#.3x, discarded",
"STUN indication with unknown method %#.3x, discarded",
static_cast<unsigned int>(indication->GetMethod()));

return;
}

// Nothig else to do. We just discard STUN Binding Indications.
// Nothig else to do. We just discard STUN Binding indications.
}

void IceServer::ProcessStunResponse(RTC::StunPacket* response)
{
MS_TRACE();

const std::string responseType = response->GetClass() == RTC::StunPacket::Class::SUCCESS_RESPONSE
? "Success"
: std::to_string(response->GetErrorCode()) + " Error";
? "success"
: std::to_string(response->GetErrorCode()) + " error";

MS_DEBUG_DEV("processing STUN %s Response", responseType.c_str());
MS_DEBUG_DEV("processing STUN %s response", responseType.c_str());

// Must be a Binding method.
if (response->GetMethod() != RTC::StunPacket::Method::BINDING)
{
MS_WARN_TAG(
ice,
"STUN %s Response with unknown method %#.3x, discarded",
"STUN %s response with unknown method %#.3x, discarded",
responseType.c_str(),
static_cast<unsigned int>(response->GetMethod()));

return;
}

// Must use FINGERPRINT (optional for ICE STUN indications).
// Must have FINGERPRINT attribute.
if (!response->HasFingerprint())
{
MS_WARN_TAG(
ice,
"STUN Binding %s Response without FINGERPRINT attribute, discarded",
"STUN Binding %s response without FINGERPRINT attribute, discarded",
responseType.c_str());

return;
Expand All @@ -521,7 +521,7 @@ namespace RTC
case RTC::StunPacket::Authentication::UNAUTHORIZED:
{
MS_WARN_TAG(
ice, "STUN %s Response with wrong authentication, discarded", responseType.c_str());
ice, "STUN %s response with wrong authentication, discarded", responseType.c_str());

return;
}
Expand All @@ -530,7 +530,7 @@ namespace RTC
{
MS_WARN_TAG(
ice,
"cannot check authentication in STUN Binding %s Response, discarded",
"cannot check authentication in STUN Binding %s response, discarded",
responseType.c_str());

return;
Expand All @@ -540,7 +540,7 @@ namespace RTC
if (!IsConsentCheckSupported())
{
MS_WARN_DEV(
"ignoring STUN Binding %s Response because ICE consent check is not supported",
"ignoring STUN Binding %s response because ICE consent check is not supported",
responseType.c_str());

return;
Expand All @@ -550,18 +550,18 @@ namespace RTC
else if (!IsConsentCheckRunning())
{
MS_DEBUG_DEV(
"ignoring STUN Binding %s Response because ICE consent check is not running",
"ignoring STUN Binding %s response because ICE consent check is not running",
responseType.c_str());

return;
}

// Trick: We only read the fist 4 bytes of the transactionId of the
// response since we know that we generated 4 bytes followed by 8 zeroed
// bytes in the transactionId of the sent consent Request.
// bytes in the transactionId of the sent consent request.
auto transactionId = Utils::Byte::Get4Bytes(response->GetTransactionId(), 0);

// Let's iterate all entries in the queue and remove the consent Request
// Let's iterate all entries in the queue and remove the consent request
// associated to this response and all those that were sent before.

// Find the associated entry first.
Expand All @@ -574,8 +574,8 @@ namespace RTC
if (it != this->sentConsents.end())
{
// If a success response or any non 403 error, let's behave the same way
// by deleting the matching sent consent Request and all previous ones.
// This way, if a strict ICE endpoint replies 400 to our consent Requests
// by deleting the matching sent consent request and all previous ones.
// This way, if a strict ICE endpoint replies 400 to our consent requests
// (because indeed mediasoup as ICE Lite server should not send requests)
// we know that the endpoint is alive, which is what ICE consent mechanism
// is about anyway.
Expand All @@ -589,7 +589,7 @@ namespace RTC
{
MS_WARN_TAG(
ice,
"ICE consent revoked by the endpoint by means of a 403 response to our ICE consent Request, moving to 'disconnected' state");
"ICE consent revoked by the endpoint by means of a 403 response to our ICE consent request, moving to 'disconnected' state");

ConsentTerminated();
}
Expand All @@ -598,7 +598,7 @@ namespace RTC
{
MS_WARN_TAG(
ice,
"STUN %s Response doesn't match any sent consent Request, discarded",
"STUN %s response doesn't match any sent consent request, discarded",
responseType.c_str());
}
}
Expand Down Expand Up @@ -1006,7 +1006,7 @@ namespace RTC
this->consentCheckTimer->Stop();
}

// Clear queue of ongoing sent ICE consent Requests.
// Clear queue of ongoing sent ICE consent requests.
this->sentConsents.clear();
}

Expand All @@ -1019,7 +1019,7 @@ namespace RTC
return;
}

// Clear queue of ongoing sent ICE consent Requests.
// Clear queue of ongoing sent ICE consent requests.
this->sentConsents.clear();

MayStartConsentCheck();
Expand All @@ -1045,9 +1045,9 @@ namespace RTC

MS_ASSERT(
this->state == IceState::CONNECTED || this->state == IceState::COMPLETED,
"cannot send ICE consent Request in state other than 'connected' or 'completed'");
"cannot send ICE consent request in state other than 'connected' or 'completed'");

MS_ASSERT(this->selectedTuple, "cannot send ICE consent Request without a selected tuple");
MS_ASSERT(this->selectedTuple, "cannot send ICE consent request without a selected tuple");

// Here we do a trick. We generate a transactionId of 4 bytes and fill the
// latest 8 bytes of the transactionId with zeroes.
Expand Down Expand Up @@ -1075,7 +1075,7 @@ namespace RTC
request->Authenticate(this->remotePassword);
request->Serialize(StunSerializeBuffer);

MS_DEBUG_DEV("sending ICE consent Request");
MS_DEBUG_DEV("sending ICE consent request");

this->listener->OnIceServerSendStunPacket(this, request, this->selectedTuple);

Expand Down Expand Up @@ -1125,7 +1125,7 @@ namespace RTC
// There should be a selected tuple.
MS_ASSERT(this->selectedTuple, "ICE consent check timer fired but there is not selected tuple");

// Check if there is at least an ongoing expired ICE Consent Request
// Check if there is at least an ongoing expired ICE consent request
// and if so move to disconnected state.

auto nowMs = DepLibUV::GetTimeMs();
Expand All @@ -1139,11 +1139,11 @@ namespace RTC

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

/*
* The interval between ICE Consent Requests is varied randomly over the
* 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.
*/
Expand Down
24 changes: 12 additions & 12 deletions worker/src/RTC/StunPacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,16 +371,16 @@ namespace RTC
switch (this->klass)
{
case Class::REQUEST:
klass = "Request";
klass = "request";
break;
case Class::INDICATION:
klass = "Indication";
klass = "indication";
break;
case Class::SUCCESS_RESPONSE:
klass = "SuccessResponse";
klass = "success response";
break;
case Class::ERROR_RESPONSE:
klass = "ErrorResponse";
klass = "error response";
break;
}
if (this->method == Method::BINDING)
Expand Down Expand Up @@ -474,15 +474,15 @@ namespace RTC
// usernameFragment1 must be given.
if (usernameFragment1.empty())
{
MS_WARN_TAG(ice, "usernameFragment1 not given, cannot authenticate Request or Indication");
MS_WARN_TAG(ice, "usernameFragment1 not given, cannot authenticate request or indication");

return Authentication::BAD_MESSAGE;
}

// USERNAME attribute must be present.
if (this->username.empty())
{
MS_WARN_TAG(ice, "missing USERNAME attribute, cannot authenticate Request or Indication");
MS_WARN_TAG(ice, "missing USERNAME attribute, cannot authenticate request or indication");

return Authentication::BAD_MESSAGE;
}
Expand All @@ -491,7 +491,7 @@ namespace RTC
if (!this->messageIntegrity)
{
MS_WARN_TAG(
ice, "missing MESSAGE-INTEGRITY attribute, cannot authenticate Request or Indication");
ice, "missing MESSAGE-INTEGRITY attribute, cannot authenticate request or indication");

return Authentication::BAD_MESSAGE;
}
Expand Down Expand Up @@ -536,7 +536,7 @@ namespace RTC
// MESSAGE-INTEGRITY attribute must be present.
if (!this->messageIntegrity)
{
MS_WARN_TAG(ice, "missing MESSAGE-INTEGRITY attribute, cannot authenticate Response");
MS_WARN_TAG(ice, "missing MESSAGE-INTEGRITY attribute, cannot authenticate response");

return Authentication::BAD_MESSAGE;
}
Expand Down Expand Up @@ -587,7 +587,7 @@ namespace RTC

MS_ASSERT(
this->klass == Class::REQUEST,
"attempt to create a success response for a non Request STUN packet");
"attempt to create a success response for a non request STUN packet");

return new StunPacket(Class::SUCCESS_RESPONSE, this->method, this->transactionId, nullptr, 0);
}
Expand All @@ -598,7 +598,7 @@ namespace RTC

MS_ASSERT(
this->klass == Class::REQUEST,
"attempt to create an error response for a non Request STUN packet");
"attempt to create an error response for a non request STUN packet");

auto* response =
new StunPacket(Class::ERROR_RESPONSE, this->method, this->transactionId, nullptr, 0);
Expand All @@ -610,10 +610,10 @@ namespace RTC

void StunPacket::Authenticate(const std::string& password)
{
// Just for Request, Indication and SuccessResponse messages.
// Just for request, indication and success response messages.
if (this->klass == Class::ERROR_RESPONSE)
{
MS_ERROR("cannot set password for ErrorResponse messages");
MS_ERROR("cannot set password for error responses");

return;
}
Expand Down

0 comments on commit 9e4eac9

Please sign in to comment.