Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
b66673c6
Unverified
提交
b66673c6
authored
10月 23, 2023
作者:
Iñaki Baz Castillo
提交者:
GitHub
10月 23, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix IceServer crash when client uses ICE renomination (#1182)
上级
80d668f6
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
88 行增加
和
46 行删除
+88
-46
CHANGELOG.md
CHANGELOG.md
+5
-0
IceServer.hpp
worker/include/RTC/IceServer.hpp
+6
-4
IceServer.cpp
worker/src/RTC/IceServer.cpp
+75
-40
WebRtcTransport.cpp
worker/src/RTC/WebRtcTransport.cpp
+2
-2
没有找到文件。
CHANGELOG.md
浏览文件 @
b66673c6
# Changelog
# Changelog
### Next
*
Fix
`IceServer`
crash when client uses ICE renomination (
[
PR #1182
](
https://github.com/versatica/mediasoup/pull/1182
)
).
### 3.12.15
### 3.12.15
*
Fix NPM "postinstall" task in Windows (
[
PR #1187
](
https://github.com/versatica/mediasoup/pull/1187
)
).
*
Fix NPM "postinstall" task in Windows (
[
PR #1187
](
https://github.com/versatica/mediasoup/pull/1187
)
).
...
...
worker/include/RTC/IceServer.hpp
浏览文件 @
b66673c6
...
@@ -93,9 +93,11 @@ namespace RTC
...
@@ -93,9 +93,11 @@ namespace RTC
}
}
bool
IsValidTuple
(
const
RTC
::
TransportTuple
*
tuple
)
const
;
bool
IsValidTuple
(
const
RTC
::
TransportTuple
*
tuple
)
const
;
void
RemoveTuple
(
RTC
::
TransportTuple
*
tuple
);
void
RemoveTuple
(
RTC
::
TransportTuple
*
tuple
);
// This should be just called in 'connected' or completed' state
/**
// and the given tuple must be an already valid tuple.
* This should be just called in 'connected' or 'completed' state and the
void
ForceSelectedTuple
(
const
RTC
::
TransportTuple
*
tuple
);
* given tuple must be an already valid tuple.
*/
void
MayForceSelectedTuple
(
const
RTC
::
TransportTuple
*
tuple
);
private
:
private
:
void
HandleTuple
(
void
HandleTuple
(
...
@@ -122,8 +124,8 @@ namespace RTC
...
@@ -122,8 +124,8 @@ namespace RTC
std
::
string
password
;
std
::
string
password
;
std
::
string
oldUsernameFragment
;
std
::
string
oldUsernameFragment
;
std
::
string
oldPassword
;
std
::
string
oldPassword
;
uint32_t
remoteNomination
{
0u
};
IceState
state
{
IceState
::
NEW
};
IceState
state
{
IceState
::
NEW
};
uint32_t
remoteNomination
{
0u
};
std
::
list
<
RTC
::
TransportTuple
>
tuples
;
std
::
list
<
RTC
::
TransportTuple
>
tuples
;
RTC
::
TransportTuple
*
selectedTuple
{
nullptr
};
RTC
::
TransportTuple
*
selectedTuple
{
nullptr
};
};
};
...
...
worker/src/RTC/IceServer.cpp
浏览文件 @
b66673c6
...
@@ -220,9 +220,13 @@ namespace RTC
...
@@ -220,9 +220,13 @@ namespace RTC
// Authenticate the response.
// Authenticate the response.
if
(
this
->
oldPassword
.
empty
())
if
(
this
->
oldPassword
.
empty
())
{
response
->
Authenticate
(
this
->
password
);
response
->
Authenticate
(
this
->
password
);
}
else
else
{
response
->
Authenticate
(
this
->
oldPassword
);
response
->
Authenticate
(
this
->
oldPassword
);
}
// Send back.
// Send back.
response
->
Serialize
(
StunSerializeBuffer
);
response
->
Serialize
(
StunSerializeBuffer
);
...
@@ -233,7 +237,9 @@ namespace RTC
...
@@ -233,7 +237,9 @@ namespace RTC
uint32_t
nomination
{
0u
};
uint32_t
nomination
{
0u
};
if
(
packet
->
HasNomination
())
if
(
packet
->
HasNomination
())
{
nomination
=
packet
->
GetNomination
();
nomination
=
packet
->
GetNomination
();
}
// Handle the tuple.
// Handle the tuple.
HandleTuple
(
tuple
,
packet
->
HasUseCandidate
(),
packet
->
HasNomination
(),
nomination
);
HandleTuple
(
tuple
,
packet
->
HasUseCandidate
(),
packet
->
HasNomination
(),
nomination
);
...
@@ -294,7 +300,9 @@ namespace RTC
...
@@ -294,7 +300,9 @@ namespace RTC
// If not found, ignore.
// If not found, ignore.
if
(
!
removedTuple
)
if
(
!
removedTuple
)
{
return
;
return
;
}
// Notify the listener.
// Notify the listener.
this
->
listener
->
OnIceServerTupleRemoved
(
this
,
removedTuple
);
this
->
listener
->
OnIceServerTupleRemoved
(
this
,
removedTuple
);
...
@@ -319,24 +327,35 @@ namespace RTC
...
@@ -319,24 +327,35 @@ namespace RTC
{
{
// Update state.
// Update state.
this
->
state
=
IceState
::
DISCONNECTED
;
this
->
state
=
IceState
::
DISCONNECTED
;
// Reset remote nomination.
this
->
remoteNomination
=
0u
;
// Notify the listener.
// Notify the listener.
this
->
listener
->
OnIceServerDisconnected
(
this
);
this
->
listener
->
OnIceServerDisconnected
(
this
);
}
}
}
}
}
}
void
IceServer
::
ForceSelectedTuple
(
const
RTC
::
TransportTuple
*
tuple
)
void
IceServer
::
May
ForceSelectedTuple
(
const
RTC
::
TransportTuple
*
tuple
)
{
{
MS_TRACE
();
MS_TRACE
();
MS_ASSERT
(
if
(
this
->
state
!=
IceState
::
CONNECTED
&&
this
->
state
!=
IceState
::
COMPLETED
)
this
->
selectedTuple
,
"cannot force the selected tuple if there was not a selected tuple"
);
{
MS_WARN_TAG
(
ice
,
"cannot force selected tuple if not in state 'connected' or 'completed'"
);
return
;
}
auto
*
storedTuple
=
HasTuple
(
tuple
);
auto
*
storedTuple
=
HasTuple
(
tuple
);
MS_ASSERT
(
if
(
!
storedTuple
)
storedTuple
,
{
"cannot force the selected tuple if the given tuple was not already a valid tuple"
);
MS_WARN_TAG
(
ice
,
"cannot force selected tuple if the given tuple was not already a valid one"
);
return
;
}
// Mark it as selected tuple.
// Mark it as selected tuple.
SetSelectedTuple
(
storedTuple
);
SetSelectedTuple
(
storedTuple
);
...
@@ -351,10 +370,6 @@ namespace RTC
...
@@ -351,10 +370,6 @@ namespace RTC
{
{
case
IceState
:
:
NEW
:
case
IceState
:
:
NEW
:
{
{
// There should be no tuples.
MS_ASSERT
(
this
->
tuples
.
empty
(),
"state is 'new' but there are %zu tuples"
,
this
->
tuples
.
size
());
// There shouldn't be a selected tuple.
// There shouldn't be a selected tuple.
MS_ASSERT
(
!
this
->
selectedTuple
,
"state is 'new' but there is selected tuple"
);
MS_ASSERT
(
!
this
->
selectedTuple
,
"state is 'new' but there is selected tuple"
);
...
@@ -373,8 +388,10 @@ namespace RTC
...
@@ -373,8 +388,10 @@ namespace RTC
// Mark it as selected tuple.
// Mark it as selected tuple.
SetSelectedTuple
(
storedTuple
);
SetSelectedTuple
(
storedTuple
);
// Update state.
// Update state.
this
->
state
=
IceState
::
CONNECTED
;
this
->
state
=
IceState
::
CONNECTED
;
// Notify the listener.
// Notify the listener.
this
->
listener
->
OnIceServerConnected
(
this
);
this
->
listener
->
OnIceServerConnected
(
this
);
}
}
...
@@ -395,11 +412,16 @@ namespace RTC
...
@@ -395,11 +412,16 @@ namespace RTC
// Mark it as selected tuple.
// Mark it as selected tuple.
SetSelectedTuple
(
storedTuple
);
SetSelectedTuple
(
storedTuple
);
// Update state.
// Update state.
this
->
state
=
IceState
::
COMPLETED
;
this
->
state
=
IceState
::
COMPLETED
;
// Update nomination.
// Update nomination.
if
(
hasNomination
&&
nomination
>
this
->
remoteNomination
)
if
(
hasNomination
&&
nomination
>
this
->
remoteNomination
)
{
this
->
remoteNomination
=
nomination
;
this
->
remoteNomination
=
nomination
;
}
// Notify the listener.
// Notify the listener.
this
->
listener
->
OnIceServerCompleted
(
this
);
this
->
listener
->
OnIceServerCompleted
(
this
);
}
}
...
@@ -410,12 +432,6 @@ namespace RTC
...
@@ -410,12 +432,6 @@ namespace RTC
case
IceState
:
:
DISCONNECTED
:
case
IceState
:
:
DISCONNECTED
:
{
{
// There should be no tuples.
MS_ASSERT
(
this
->
tuples
.
empty
(),
"state is 'disconnected' but there are %zu tuples"
,
this
->
tuples
.
size
());
// There shouldn't be a selected tuple.
// There shouldn't be a selected tuple.
MS_ASSERT
(
!
this
->
selectedTuple
,
"state is 'disconnected' but there is selected tuple"
);
MS_ASSERT
(
!
this
->
selectedTuple
,
"state is 'disconnected' but there is selected tuple"
);
...
@@ -434,8 +450,10 @@ namespace RTC
...
@@ -434,8 +450,10 @@ namespace RTC
// Mark it as selected tuple.
// Mark it as selected tuple.
SetSelectedTuple
(
storedTuple
);
SetSelectedTuple
(
storedTuple
);
// Update state.
// Update state.
this
->
state
=
IceState
::
CONNECTED
;
this
->
state
=
IceState
::
CONNECTED
;
// Notify the listener.
// Notify the listener.
this
->
listener
->
OnIceServerConnected
(
this
);
this
->
listener
->
OnIceServerConnected
(
this
);
}
}
...
@@ -456,11 +474,16 @@ namespace RTC
...
@@ -456,11 +474,16 @@ namespace RTC
// Mark it as selected tuple.
// Mark it as selected tuple.
SetSelectedTuple
(
storedTuple
);
SetSelectedTuple
(
storedTuple
);
// Update state.
// Update state.
this
->
state
=
IceState
::
COMPLETED
;
this
->
state
=
IceState
::
COMPLETED
;
// Update nomination.
// Update nomination.
if
(
hasNomination
&&
nomination
>
this
->
remoteNomination
)
if
(
hasNomination
&&
nomination
>
this
->
remoteNomination
)
{
this
->
remoteNomination
=
nomination
;
this
->
remoteNomination
=
nomination
;
}
// Notify the listener.
// Notify the listener.
this
->
listener
->
OnIceServerCompleted
(
this
);
this
->
listener
->
OnIceServerCompleted
(
this
);
}
}
...
@@ -479,9 +502,8 @@ namespace RTC
...
@@ -479,9 +502,8 @@ namespace RTC
if
(
!
hasUseCandidate
&&
!
hasNomination
)
if
(
!
hasUseCandidate
&&
!
hasNomination
)
{
{
// If a new tuple store it.
// Store the tuple.
if
(
!
HasTuple
(
tuple
))
AddTuple
(
tuple
);
AddTuple
(
tuple
);
}
}
else
else
{
{
...
@@ -493,21 +515,23 @@ namespace RTC
...
@@ -493,21 +515,23 @@ namespace RTC
hasNomination
?
"true"
:
"false"
,
hasNomination
?
"true"
:
"false"
,
nomination
);
nomination
);
auto
*
storedTuple
=
HasTuple
(
tuple
);
// Store the tuple.
auto
*
storedTuple
=
AddTuple
(
tuple
);
// If a new tuple store it.
if
(
!
storedTuple
)
storedTuple
=
AddTuple
(
tuple
);
if
((
hasNomination
&&
nomination
>
this
->
remoteNomination
)
||
!
hasNomination
)
if
((
hasNomination
&&
nomination
>
this
->
remoteNomination
)
||
!
hasNomination
)
{
{
// Mark it as selected tuple.
// Mark it as selected tuple.
SetSelectedTuple
(
storedTuple
);
SetSelectedTuple
(
storedTuple
);
// Update state.
// Update state.
this
->
state
=
IceState
::
COMPLETED
;
this
->
state
=
IceState
::
COMPLETED
;
// Update nomination.
// Update nomination.
if
(
hasNomination
&&
nomination
>
this
->
remoteNomination
)
if
(
hasNomination
&&
nomination
>
this
->
remoteNomination
)
{
this
->
remoteNomination
=
nomination
;
this
->
remoteNomination
=
nomination
;
}
// Notify the listener.
// Notify the listener.
this
->
listener
->
OnIceServerCompleted
(
this
);
this
->
listener
->
OnIceServerCompleted
(
this
);
}
}
...
@@ -526,25 +550,24 @@ namespace RTC
...
@@ -526,25 +550,24 @@ namespace RTC
if
(
!
hasUseCandidate
&&
!
hasNomination
)
if
(
!
hasUseCandidate
&&
!
hasNomination
)
{
{
// If a new tuple store it.
// Store the tuple.
if
(
!
HasTuple
(
tuple
))
AddTuple
(
tuple
);
AddTuple
(
tuple
);
}
}
else
else
{
{
auto
*
storedTuple
=
HasTuple
(
tuple
);
// Store the tuple.
auto
*
storedTuple
=
AddTuple
(
tuple
);
// If a new tuple store it.
if
(
!
storedTuple
)
storedTuple
=
AddTuple
(
tuple
);
if
((
hasNomination
&&
nomination
>
this
->
remoteNomination
)
||
!
hasNomination
)
if
((
hasNomination
&&
nomination
>
this
->
remoteNomination
)
||
!
hasNomination
)
{
{
// Mark it as selected tuple.
// Mark it as selected tuple.
SetSelectedTuple
(
storedTuple
);
SetSelectedTuple
(
storedTuple
);
// Update nomination.
// Update nomination.
if
(
hasNomination
&&
nomination
>
this
->
remoteNomination
)
if
(
hasNomination
&&
nomination
>
this
->
remoteNomination
)
{
this
->
remoteNomination
=
nomination
;
this
->
remoteNomination
=
nomination
;
}
}
}
}
}
...
@@ -557,15 +580,26 @@ namespace RTC
...
@@ -557,15 +580,26 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
auto
*
storedTuple
=
HasTuple
(
tuple
);
if
(
storedTuple
)
{
MS_DEBUG_DEV
(
'
tuple
already
exists
'
);
return
storedTuple
;
}
// Add the new tuple at the beginning of the list.
// Add the new tuple at the beginning of the list.
this
->
tuples
.
push_front
(
*
tuple
);
this
->
tuples
.
push_front
(
*
tuple
);
auto
*
storedTuple
=
std
::
addressof
(
*
this
->
tuples
.
begin
());
storedTuple
=
std
::
addressof
(
*
this
->
tuples
.
begin
());
// If it is UDP then we must store the remote address (until now it is
// If it is UDP then we must store the remote address (until now it is
// just a pointer that will be freed soon).
// just a pointer that will be freed soon).
if
(
storedTuple
->
GetProtocol
()
==
TransportTuple
::
Protocol
::
UDP
)
if
(
storedTuple
->
GetProtocol
()
==
TransportTuple
::
Protocol
::
UDP
)
{
storedTuple
->
StoreUdpRemoteAddress
();
storedTuple
->
StoreUdpRemoteAddress
();
}
// Notify the listener.
// Notify the listener.
this
->
listener
->
OnIceServerTupleAdded
(
this
,
storedTuple
);
this
->
listener
->
OnIceServerTupleAdded
(
this
,
storedTuple
);
...
@@ -614,14 +648,11 @@ namespace RTC
...
@@ -614,14 +648,11 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
// If there is no selected tuple yet then we know that the tuples list
// Check the current selected tuple (if any).
// is empty.
if
(
this
->
selectedTuple
&&
this
->
selectedTuple
->
Compare
(
tuple
))
if
(
!
this
->
selectedTuple
)
{
return
nullptr
;
// Check the current selected tuple.
if
(
this
->
selectedTuple
->
Compare
(
tuple
))
return
this
->
selectedTuple
;
return
this
->
selectedTuple
;
}
// Otherwise check other stored tuples.
// Otherwise check other stored tuples.
for
(
const
auto
&
it
:
this
->
tuples
)
for
(
const
auto
&
it
:
this
->
tuples
)
...
@@ -629,7 +660,9 @@ namespace RTC
...
@@ -629,7 +660,9 @@ namespace RTC
auto
*
storedTuple
=
const_cast
<
RTC
::
TransportTuple
*>
(
std
::
addressof
(
it
));
auto
*
storedTuple
=
const_cast
<
RTC
::
TransportTuple
*>
(
std
::
addressof
(
it
));
if
(
storedTuple
->
Compare
(
tuple
))
if
(
storedTuple
->
Compare
(
tuple
))
{
return
storedTuple
;
return
storedTuple
;
}
}
}
return
nullptr
;
return
nullptr
;
...
@@ -641,7 +674,9 @@ namespace RTC
...
@@ -641,7 +674,9 @@ namespace RTC
// If already the selected tuple do nothing.
// If already the selected tuple do nothing.
if
(
storedTuple
==
this
->
selectedTuple
)
if
(
storedTuple
==
this
->
selectedTuple
)
{
return
;
return
;
}
this
->
selectedTuple
=
storedTuple
;
this
->
selectedTuple
=
storedTuple
;
...
...
worker/src/RTC/WebRtcTransport.cpp
浏览文件 @
b66673c6
...
@@ -1058,7 +1058,7 @@ namespace RTC
...
@@ -1058,7 +1058,7 @@ namespace RTC
}
}
// Trick for clients performing aggressive ICE regardless we are ICE-Lite.
// Trick for clients performing aggressive ICE regardless we are ICE-Lite.
this
->
iceServer
->
ForceSelectedTuple
(
tuple
);
this
->
iceServer
->
May
ForceSelectedTuple
(
tuple
);
// Check that DTLS status is 'connecting' or 'connected'.
// Check that DTLS status is 'connecting' or 'connected'.
if
(
if
(
...
@@ -1142,7 +1142,7 @@ namespace RTC
...
@@ -1142,7 +1142,7 @@ namespace RTC
}
}
// Trick for clients performing aggressive ICE regardless we are ICE-Lite.
// Trick for clients performing aggressive ICE regardless we are ICE-Lite.
this
->
iceServer
->
ForceSelectedTuple
(
tuple
);
this
->
iceServer
->
May
ForceSelectedTuple
(
tuple
);
// Pass the packet to the parent transport.
// Pass the packet to the parent transport.
RTC
::
Transport
::
ReceiveRtpPacket
(
packet
);
RTC
::
Transport
::
ReceiveRtpPacket
(
packet
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论