Skip to content

Commit

Permalink
Improve StunPacket::Dump() and CheckAuthentication()
Browse files Browse the repository at this point in the history
  • Loading branch information
ibc committed Feb 19, 2024
1 parent 9e4eac9 commit 2c95e29
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions worker/src/RTC/StunPacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,14 +394,11 @@ namespace RTC
}
MS_DUMP(" size: %zu bytes", this->size);

char transactionId[25];
auto transactionId1 = Utils::Byte::Get4Bytes(this->transactionId, 0);
auto transactionId2 = Utils::Byte::Get8Bytes(this->transactionId, 4);

for (int i{ 0 }; i < 12; ++i)
{
// NOTE: n must be 3 because snprintf adds a \0 after printed chars.
std::snprintf(transactionId + (i * 2), 3, "%.2x", this->transactionId[i]);
}
MS_DUMP(" transactionId: %s", transactionId);
MS_DUMP(" transactionId (first 4 bytes): %" PRIu32, transactionId1);
MS_DUMP(" transactionId (last 8 bytes): %" PRIu64, transactionId2);
if (this->errorCode != 0u)
{
MS_DUMP(" errorCode: %" PRIu16, this->errorCode);
Expand Down Expand Up @@ -543,6 +540,13 @@ namespace RTC

break;
}

default:
{
MS_WARN_TAG(ice, "unknown STUN class %" PRIu16 ", cannot authenticate", this->klass);

return Authentication::BAD_MESSAGE;
}
}

// If there is FINGERPRINT it must be discarded for MESSAGE-INTEGRITY
Expand Down

0 comments on commit 2c95e29

Please sign in to comment.