Fix a bug in WebRTC where the DTLS certificate is too large(big than MTU) (#3250)

This commit is contained in:
老衲不出家 2024-01-24 15:14:23 +08:00 committed by GitHub
parent f9da87eb5d
commit 62641f426b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -201,9 +201,26 @@ void WebRtcTransport::OnDtlsTransportConnected(
onStartWebRTC();
}
#pragma pack(push, 1)
struct DtlsHeader {
uint8_t content_type;
uint16_t dtls_version;
uint16_t epoch;
uint8_t seq[6];
uint16_t length;
uint8_t payload[1];
};
#pragma pack(pop)
void WebRtcTransport::OnDtlsTransportSendData(
const RTC::DtlsTransport *dtlsTransport, const uint8_t *data, size_t len) {
sendSockData((char *)data, len, nullptr);
size_t offset = 0;
while(offset < len) {
auto *header = reinterpret_cast<const DtlsHeader *>(data + offset);
auto length = ntohs(header->length) + offsetof(DtlsHeader, payload);
sendSockData((char *)data + offset, length, nullptr);
offset += length;
}
}
void WebRtcTransport::OnDtlsTransportConnecting(const RTC::DtlsTransport *dtlsTransport) {