mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
修复webrtc相关漏洞:#1110
This commit is contained in:
parent
03aa9290ab
commit
00f01afec7
@ -243,6 +243,10 @@ bool is_rtcp(char *buf) {
|
|||||||
return ((header->pt >= 64) && (header->pt < 96));
|
return ((header->pt >= 64) && (header->pt < 96));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static string getPeerAddress(RTC::TransportTuple *tuple){
|
||||||
|
return SockUtil::inet_ntoa(((struct sockaddr_in *)tuple)->sin_addr) + ":" + to_string(ntohs(((struct sockaddr_in *)tuple)->sin_port));
|
||||||
|
}
|
||||||
|
|
||||||
void WebRtcTransport::inputSockData(char *buf, int len, RTC::TransportTuple *tuple) {
|
void WebRtcTransport::inputSockData(char *buf, int len, RTC::TransportTuple *tuple) {
|
||||||
if (RTC::StunPacket::IsStun((const uint8_t *) buf, len)) {
|
if (RTC::StunPacket::IsStun((const uint8_t *) buf, len)) {
|
||||||
std::unique_ptr<RTC::StunPacket> packet(RTC::StunPacket::Parse((const uint8_t *) buf, len));
|
std::unique_ptr<RTC::StunPacket> packet(RTC::StunPacket::Parse((const uint8_t *) buf, len));
|
||||||
@ -258,12 +262,20 @@ void WebRtcTransport::inputSockData(char *buf, int len, RTC::TransportTuple *tup
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (is_rtp(buf)) {
|
if (is_rtp(buf)) {
|
||||||
|
if (!_srtp_session_recv) {
|
||||||
|
WarnL << "received rtp packet when dtls not completed from:" << getPeerAddress(tuple);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (_srtp_session_recv->DecryptSrtp((uint8_t *) buf, &len)) {
|
if (_srtp_session_recv->DecryptSrtp((uint8_t *) buf, &len)) {
|
||||||
onRtp(buf, len);
|
onRtp(buf, len);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (is_rtcp(buf)) {
|
if (is_rtcp(buf)) {
|
||||||
|
if (!_srtp_session_recv) {
|
||||||
|
WarnL << "received rtcp packet when dtls not completed from:" << getPeerAddress(tuple);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (_srtp_session_recv->DecryptSrtcp((uint8_t *) buf, &len)) {
|
if (_srtp_session_recv->DecryptSrtcp((uint8_t *) buf, &len)) {
|
||||||
onRtcp(buf, len);
|
onRtcp(buf, len);
|
||||||
}
|
}
|
||||||
@ -382,6 +394,8 @@ void WebRtcTransportImp::onSendSockData(const char *buf, size_t len, struct sock
|
|||||||
}
|
}
|
||||||
auto ptr = BufferRaw::create();
|
auto ptr = BufferRaw::create();
|
||||||
ptr->assign(buf, len);
|
ptr->assign(buf, len);
|
||||||
|
//一次性发送一帧的rtp数据,提高网络io性能
|
||||||
|
_session->setSendFlushFlag(flush);
|
||||||
_session->send(std::move(ptr));
|
_session->send(std::move(ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user