Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
c693e224
Unverified
提交
c693e224
authored
1月 14, 2022
作者:
Iñaki Baz Castillo
提交者:
GitHub
1月 14, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ICE renomination support (#756)
上级
55c6015e
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
142 行增加
和
45 行删除
+142
-45
IceServer.hpp
worker/include/RTC/IceServer.hpp
+7
-5
StunPacket.hpp
worker/include/RTC/StunPacket.hpp
+24
-5
IceServer.cpp
worker/src/RTC/IceServer.cpp
+93
-33
StunPacket.cpp
worker/src/RTC/StunPacket.cpp
+17
-0
WebRtcTransport.cpp
worker/src/RTC/WebRtcTransport.cpp
+1
-2
没有找到文件。
worker/include/RTC/IceServer.hpp
浏览文件 @
c693e224
...
@@ -61,15 +61,15 @@ namespace RTC
...
@@ -61,15 +61,15 @@ namespace RTC
{
{
return
this
->
selectedTuple
;
return
this
->
selectedTuple
;
}
}
void
SetUsernameFragment
(
const
std
::
string
&
usernameFragment
)
void
RestartIce
(
const
std
::
string
&
usernameFragment
,
const
std
::
string
&
password
)
{
{
this
->
oldUsernameFragment
=
this
->
usernameFragment
;
this
->
oldUsernameFragment
=
this
->
usernameFragment
;
this
->
usernameFragment
=
usernameFragment
;
this
->
usernameFragment
=
usernameFragment
;
}
void
SetPassword
(
const
std
::
string
&
password
)
{
this
->
oldPassword
=
this
->
password
;
this
->
oldPassword
=
this
->
password
;
this
->
password
=
password
;
this
->
password
=
password
;
this
->
remoteNomination
=
0u
;
}
}
bool
IsValidTuple
(
const
RTC
::
TransportTuple
*
tuple
)
const
;
bool
IsValidTuple
(
const
RTC
::
TransportTuple
*
tuple
)
const
;
void
RemoveTuple
(
RTC
::
TransportTuple
*
tuple
);
void
RemoveTuple
(
RTC
::
TransportTuple
*
tuple
);
...
@@ -78,7 +78,8 @@ namespace RTC
...
@@ -78,7 +78,8 @@ namespace RTC
void
ForceSelectedTuple
(
const
RTC
::
TransportTuple
*
tuple
);
void
ForceSelectedTuple
(
const
RTC
::
TransportTuple
*
tuple
);
private
:
private
:
void
HandleTuple
(
RTC
::
TransportTuple
*
tuple
,
bool
hasUseCandidate
);
void
HandleTuple
(
RTC
::
TransportTuple
*
tuple
,
bool
hasUseCandidate
,
bool
hasNomination
,
uint32_t
nomination
);
/**
/**
* Store the given tuple and return its stored address.
* Store the given tuple and return its stored address.
*/
*/
...
@@ -101,6 +102,7 @@ namespace RTC
...
@@ -101,6 +102,7 @@ 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
};
std
::
list
<
RTC
::
TransportTuple
>
tuples
;
std
::
list
<
RTC
::
TransportTuple
>
tuples
;
RTC
::
TransportTuple
*
selectedTuple
{
nullptr
};
RTC
::
TransportTuple
*
selectedTuple
{
nullptr
};
...
...
worker/include/RTC/StunPacket.hpp
浏览文件 @
c693e224
...
@@ -41,7 +41,8 @@ namespace RTC
...
@@ -41,7 +41,8 @@ namespace RTC
ALTERNATE_SERVER
=
0x8023
,
ALTERNATE_SERVER
=
0x8023
,
FINGERPRINT
=
0x8028
,
FINGERPRINT
=
0x8028
,
ICE_CONTROLLED
=
0x8029
,
ICE_CONTROLLED
=
0x8029
,
ICE_CONTROLLING
=
0x802A
ICE_CONTROLLING
=
0x802A
,
NOMINATION
=
0xC001
};
};
// Authentication result.
// Authentication result.
...
@@ -114,6 +115,10 @@ namespace RTC
...
@@ -114,6 +115,10 @@ namespace RTC
{
{
this
->
hasUseCandidate
=
true
;
this
->
hasUseCandidate
=
true
;
}
}
void
SetNomination
(
uint32_t
nomination
)
{
this
->
nomination
=
nomination
;
}
void
SetXorMappedAddress
(
const
struct
sockaddr
*
xorMappedAddress
)
void
SetXorMappedAddress
(
const
struct
sockaddr
*
xorMappedAddress
)
{
{
this
->
xorMappedAddress
=
xorMappedAddress
;
this
->
xorMappedAddress
=
xorMappedAddress
;
...
@@ -150,6 +155,18 @@ namespace RTC
...
@@ -150,6 +155,18 @@ namespace RTC
{
{
return
this
->
hasUseCandidate
;
return
this
->
hasUseCandidate
;
}
}
void
SetHasNomination
()
{
this
->
hasNomination
=
true
;
}
bool
HasNomination
()
const
{
return
this
->
hasNomination
;
}
uint32_t
GetNomination
()
const
{
return
this
->
nomination
;
}
uint16_t
GetErrorCode
()
const
uint16_t
GetErrorCode
()
const
{
{
return
this
->
errorCode
;
return
this
->
errorCode
;
...
@@ -177,10 +194,12 @@ namespace RTC
...
@@ -177,10 +194,12 @@ namespace RTC
uint8_t
*
data
{
nullptr
};
// Pointer to binary data.
uint8_t
*
data
{
nullptr
};
// Pointer to binary data.
size_t
size
{
0u
};
// The full message size (including header).
size_t
size
{
0u
};
// The full message size (including header).
// STUN attributes.
// STUN attributes.
std
::
string
username
;
// Less than 513 bytes.
std
::
string
username
;
// Less than 513 bytes.
uint32_t
priority
{
0u
};
// 4 bytes unsigned integer.
uint32_t
priority
{
0u
};
// 4 bytes unsigned integer.
uint64_t
iceControlling
{
0u
};
// 8 bytes unsigned integer.
uint64_t
iceControlling
{
0u
};
// 8 bytes unsigned integer.
uint64_t
iceControlled
{
0u
};
// 8 bytes unsigned integer.
uint64_t
iceControlled
{
0u
};
// 8 bytes unsigned integer.
bool
hasNomination
{
false
};
uint32_t
nomination
{
0u
};
// 4 bytes unsigned integer.
bool
hasUseCandidate
{
false
};
// 0 bytes.
bool
hasUseCandidate
{
false
};
// 0 bytes.
const
uint8_t
*
messageIntegrity
{
nullptr
};
// 20 bytes.
const
uint8_t
*
messageIntegrity
{
nullptr
};
// 20 bytes.
bool
hasFingerprint
{
false
};
// 4 bytes.
bool
hasFingerprint
{
false
};
// 4 bytes.
...
...
worker/src/RTC/IceServer.cpp
浏览文件 @
c693e224
...
@@ -198,8 +198,13 @@ namespace RTC
...
@@ -198,8 +198,13 @@ namespace RTC
delete
response
;
delete
response
;
uint32_t
nomination
{
0u
};
if
(
packet
->
HasNomination
())
nomination
=
packet
->
GetNomination
();
// Handle the tuple.
// Handle the tuple.
HandleTuple
(
tuple
,
packet
->
HasUseCandidate
());
HandleTuple
(
tuple
,
packet
->
HasUseCandidate
()
,
packet
->
HasNomination
(),
nomination
);
break
;
break
;
}
}
...
@@ -301,7 +306,8 @@ namespace RTC
...
@@ -301,7 +306,8 @@ namespace RTC
SetSelectedTuple
(
storedTuple
);
SetSelectedTuple
(
storedTuple
);
}
}
void
IceServer
::
HandleTuple
(
RTC
::
TransportTuple
*
tuple
,
bool
hasUseCandidate
)
void
IceServer
::
HandleTuple
(
RTC
::
TransportTuple
*
tuple
,
bool
hasUseCandidate
,
bool
hasNomination
,
uint32_t
nomination
)
{
{
MS_TRACE
();
MS_TRACE
();
...
@@ -316,9 +322,15 @@ namespace RTC
...
@@ -316,9 +322,15 @@ namespace RTC
// 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"
);
if
(
!
hasUseCandidate
)
if
(
!
hasUseCandidate
&&
!
hasNomination
)
{
{
MS_DEBUG_TAG
(
ice
,
"transition from state 'new' to 'connected'"
);
MS_DEBUG_TAG
(
ice
,
"transition from state 'new' to 'connected' [hasUseCandidate:%s, hasNomination:%s, nomination:%"
PRIu32
"]"
,
hasUseCandidate
?
"true"
:
"false"
,
hasNomination
?
"true"
:
"false"
,
nomination
);
// Store the tuple.
// Store the tuple.
auto
*
storedTuple
=
AddTuple
(
tuple
);
auto
*
storedTuple
=
AddTuple
(
tuple
);
...
@@ -332,17 +344,29 @@ namespace RTC
...
@@ -332,17 +344,29 @@ namespace RTC
}
}
else
else
{
{
MS_DEBUG_TAG
(
ice
,
"transition from state 'new' to 'completed'"
);
// Store the tuple.
// Store the tuple.
auto
*
storedTuple
=
AddTuple
(
tuple
);
auto
*
storedTuple
=
AddTuple
(
tuple
);
// Mark it as selected tuple.
if
((
hasNomination
&&
nomination
>
this
->
remoteNomination
)
||
!
hasNomination
)
SetSelectedTuple
(
storedTuple
);
{
// Update state.
MS_DEBUG_TAG
(
this
->
state
=
IceState
::
COMPLETED
;
ice
,
// Notify the listener.
"transition from state 'new' to 'completed' [hasUseCandidate:%s, hasNomination:%s, nomination:%"
PRIu32
this
->
listener
->
OnIceServerCompleted
(
this
);
"]"
,
hasUseCandidate
?
"true"
:
"false"
,
hasNomination
?
"true"
:
"false"
,
nomination
);
// Mark it as selected tuple.
SetSelectedTuple
(
storedTuple
);
// Update state.
this
->
state
=
IceState
::
COMPLETED
;
// Update nomination.
if
(
hasNomination
&&
nomination
>
this
->
remoteNomination
)
this
->
remoteNomination
=
nomination
;
// Notify the listener.
this
->
listener
->
OnIceServerCompleted
(
this
);
}
}
}
break
;
break
;
...
@@ -359,9 +383,15 @@ namespace RTC
...
@@ -359,9 +383,15 @@ namespace RTC
// 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"
);
if
(
!
hasUseCandidate
)
if
(
!
hasUseCandidate
&&
!
hasNomination
)
{
{
MS_DEBUG_TAG
(
ice
,
"transition from state 'disconnected' to 'connected'"
);
MS_DEBUG_TAG
(
ice
,
"transition from state 'disconnected' to 'connected' [hasUseCandidate:%s, hasNomination:%s, nomination:%"
PRIu32
"]"
,
hasUseCandidate
?
"true"
:
"false"
,
hasNomination
?
"true"
:
"false"
,
nomination
);
// Store the tuple.
// Store the tuple.
auto
*
storedTuple
=
AddTuple
(
tuple
);
auto
*
storedTuple
=
AddTuple
(
tuple
);
...
@@ -375,17 +405,29 @@ namespace RTC
...
@@ -375,17 +405,29 @@ namespace RTC
}
}
else
else
{
{
MS_DEBUG_TAG
(
ice
,
"transition from state 'disconnected' to 'completed'"
);
// Store the tuple.
// Store the tuple.
auto
*
storedTuple
=
AddTuple
(
tuple
);
auto
*
storedTuple
=
AddTuple
(
tuple
);
// Mark it as selected tuple.
if
((
hasNomination
&&
nomination
>
this
->
remoteNomination
)
||
!
hasNomination
)
SetSelectedTuple
(
storedTuple
);
{
// Update state.
MS_DEBUG_TAG
(
this
->
state
=
IceState
::
COMPLETED
;
ice
,
// Notify the listener.
"transition from state 'disconnected' to 'completed' [hasUseCandidate:%s, hasNomination:%s, nomination:%"
PRIu32
this
->
listener
->
OnIceServerCompleted
(
this
);
"]"
,
hasUseCandidate
?
"true"
:
"false"
,
hasNomination
?
"true"
:
"false"
,
nomination
);
// Mark it as selected tuple.
SetSelectedTuple
(
storedTuple
);
// Update state.
this
->
state
=
IceState
::
COMPLETED
;
// Update nomination.
if
(
hasNomination
&&
nomination
>
this
->
remoteNomination
)
this
->
remoteNomination
=
nomination
;
// Notify the listener.
this
->
listener
->
OnIceServerCompleted
(
this
);
}
}
}
break
;
break
;
...
@@ -399,7 +441,7 @@ namespace RTC
...
@@ -399,7 +441,7 @@ namespace RTC
// There should be a selected tuple.
// There should be a selected tuple.
MS_ASSERT
(
this
->
selectedTuple
,
"state is 'connected' but there is not selected tuple"
);
MS_ASSERT
(
this
->
selectedTuple
,
"state is 'connected' but there is not selected tuple"
);
if
(
!
hasUseCandidate
)
if
(
!
hasUseCandidate
&&
!
hasNomination
)
{
{
// If a new tuple store it.
// If a new tuple store it.
if
(
!
HasTuple
(
tuple
))
if
(
!
HasTuple
(
tuple
))
...
@@ -407,7 +449,13 @@ namespace RTC
...
@@ -407,7 +449,13 @@ namespace RTC
}
}
else
else
{
{
MS_DEBUG_TAG
(
ice
,
"transition from state 'connected' to 'completed'"
);
MS_DEBUG_TAG
(
ice
,
"transition from state 'connected' to 'completed' [hasUseCandidate:%s, hasNomination:%s, nomination:%"
PRIu32
"]"
,
hasUseCandidate
?
"true"
:
"false"
,
hasNomination
?
"true"
:
"false"
,
nomination
);
auto
*
storedTuple
=
HasTuple
(
tuple
);
auto
*
storedTuple
=
HasTuple
(
tuple
);
...
@@ -415,12 +463,18 @@ namespace RTC
...
@@ -415,12 +463,18 @@ namespace RTC
if
(
!
storedTuple
)
if
(
!
storedTuple
)
storedTuple
=
AddTuple
(
tuple
);
storedTuple
=
AddTuple
(
tuple
);
// Mark it as selected tuple.
if
((
hasNomination
&&
nomination
>
this
->
remoteNomination
)
||
!
hasNomination
)
SetSelectedTuple
(
storedTuple
);
{
// Update state.
// Mark it as selected tuple.
this
->
state
=
IceState
::
COMPLETED
;
SetSelectedTuple
(
storedTuple
);
// Notify the listener.
// Update state.
this
->
listener
->
OnIceServerCompleted
(
this
);
this
->
state
=
IceState
::
COMPLETED
;
// Update nomination.
if
(
hasNomination
&&
nomination
>
this
->
remoteNomination
)
this
->
remoteNomination
=
nomination
;
// Notify the listener.
this
->
listener
->
OnIceServerCompleted
(
this
);
}
}
}
break
;
break
;
...
@@ -434,7 +488,7 @@ namespace RTC
...
@@ -434,7 +488,7 @@ namespace RTC
// There should be a selected tuple.
// There should be a selected tuple.
MS_ASSERT
(
this
->
selectedTuple
,
"state is 'completed' but there is not selected tuple"
);
MS_ASSERT
(
this
->
selectedTuple
,
"state is 'completed' but there is not selected tuple"
);
if
(
!
hasUseCandidate
)
if
(
!
hasUseCandidate
&&
!
hasNomination
)
{
{
// If a new tuple store it.
// If a new tuple store it.
if
(
!
HasTuple
(
tuple
))
if
(
!
HasTuple
(
tuple
))
...
@@ -448,8 +502,14 @@ namespace RTC
...
@@ -448,8 +502,14 @@ namespace RTC
if
(
!
storedTuple
)
if
(
!
storedTuple
)
storedTuple
=
AddTuple
(
tuple
);
storedTuple
=
AddTuple
(
tuple
);
// Mark it as selected tuple.
if
((
hasNomination
&&
nomination
>
this
->
remoteNomination
)
||
!
hasNomination
)
SetSelectedTuple
(
storedTuple
);
{
// Mark it as selected tuple.
SetSelectedTuple
(
storedTuple
);
// Update nomination.
if
(
hasNomination
&&
nomination
>
this
->
remoteNomination
)
this
->
remoteNomination
=
nomination
;
}
}
}
break
;
break
;
...
...
worker/src/RTC/StunPacket.cpp
浏览文件 @
c693e224
...
@@ -209,6 +209,23 @@ namespace RTC
...
@@ -209,6 +209,23 @@ namespace RTC
break
;
break
;
}
}
case
Attribute
:
:
NOMINATION
:
{
// Ensure attribute length is 4 bytes.
if
(
attrLength
!=
4
)
{
MS_WARN_TAG
(
ice
,
"attribute NOMINATION must be 4 bytes length, packet discarded"
);
delete
packet
;
return
nullptr
;
}
packet
->
SetHasNomination
();
packet
->
SetNomination
(
Utils
::
Byte
::
Get4Bytes
(
attrValuePos
,
0
));
break
;
}
case
Attribute
:
:
MESSAGE_INTEGRITY
:
case
Attribute
:
:
MESSAGE_INTEGRITY
:
{
{
// Ensure attribute length is 20 bytes.
// Ensure attribute length is 20 bytes.
...
...
worker/src/RTC/WebRtcTransport.cpp
浏览文件 @
c693e224
...
@@ -585,8 +585,7 @@ namespace RTC
...
@@ -585,8 +585,7 @@ namespace RTC
std
::
string
usernameFragment
=
Utils
::
Crypto
::
GetRandomString
(
16
);
std
::
string
usernameFragment
=
Utils
::
Crypto
::
GetRandomString
(
16
);
std
::
string
password
=
Utils
::
Crypto
::
GetRandomString
(
32
);
std
::
string
password
=
Utils
::
Crypto
::
GetRandomString
(
32
);
this
->
iceServer
->
SetUsernameFragment
(
usernameFragment
);
this
->
iceServer
->
RestartIce
(
usernameFragment
,
password
);
this
->
iceServer
->
SetPassword
(
password
);
MS_DEBUG_DEV
(
MS_DEBUG_DEV
(
"WebRtcTransport ICE usernameFragment and password changed [id:%s]"
,
this
->
id
.
c_str
());
"WebRtcTransport ICE usernameFragment and password changed [id:%s]"
,
this
->
id
.
c_str
());
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论