Ensuring that UDP TURN servers are always used as STUN servers.
This was already working in most cases, but not for some corner cases: * If the PORTALLOCATOR_ENABLE_SHARED_SOCKET flag is not set * If both a STUN server and TURN server are configured I added unit tests for these cases, and centralized the code that gets STUN server addresses in order to fix these and any related issues. BUG=webrtc:4215 Review URL: https://codereview.webrtc.org/1215713003 Cr-Commit-Position: refs/heads/master@{#9596}
This commit is contained in:
@ -208,7 +208,7 @@ void BasicPortAllocator::Construct() {
|
||||
BasicPortAllocator::~BasicPortAllocator() {
|
||||
}
|
||||
|
||||
PortAllocatorSession *BasicPortAllocator::CreateSessionInternal(
|
||||
PortAllocatorSession* BasicPortAllocator::CreateSessionInternal(
|
||||
const std::string& content_name, int component,
|
||||
const std::string& ice_ufrag, const std::string& ice_pwd) {
|
||||
return new BasicPortAllocatorSession(
|
||||
@ -927,18 +927,10 @@ void AllocationSequence::CreateUDPPorts() {
|
||||
|
||||
// If STUN is not disabled, setting stun server address to port.
|
||||
if (!IsFlagSet(PORTALLOCATOR_DISABLE_STUN)) {
|
||||
// If config has stun_servers, use it to get server reflexive candidate
|
||||
// otherwise use first TURN server which supports UDP.
|
||||
if (config_ && !config_->StunServers().empty()) {
|
||||
LOG(LS_INFO) << "AllocationSequence: UDPPort will be handling the "
|
||||
<< "STUN candidate generation.";
|
||||
port->set_server_addresses(config_->StunServers());
|
||||
} else if (config_ &&
|
||||
config_->SupportsProtocol(RELAY_TURN, PROTO_UDP)) {
|
||||
port->set_server_addresses(config_->GetRelayServerAddresses(
|
||||
RELAY_TURN, PROTO_UDP));
|
||||
LOG(LS_INFO) << "AllocationSequence: TURN Server address will be "
|
||||
<< " used for generating STUN candidate.";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1171,6 +1163,13 @@ ServerAddresses PortConfiguration::StunServers() {
|
||||
stun_servers.find(stun_address) == stun_servers.end()) {
|
||||
stun_servers.insert(stun_address);
|
||||
}
|
||||
// Every UDP TURN server should also be used as a STUN server.
|
||||
ServerAddresses turn_servers = GetRelayServerAddresses(RELAY_TURN, PROTO_UDP);
|
||||
for (const rtc::SocketAddress& turn_server : turn_servers) {
|
||||
if (stun_servers.find(turn_server) == stun_servers.end()) {
|
||||
stun_servers.insert(turn_server);
|
||||
}
|
||||
}
|
||||
return stun_servers;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user