(Auto)update libjingle 66556498-> 66624678
git-svn-id: http://webrtc.googlecode.com/svn/trunk@6093 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
3b76627afe
commit
1cd14a4502
@ -470,10 +470,22 @@ void P2PTransportChannel::OnUnknownAddress(
|
||||
}
|
||||
} else {
|
||||
// Create a new candidate with this address.
|
||||
|
||||
uint32 priority = 0;
|
||||
std::string type;
|
||||
if (port->IceProtocol() == ICEPROTO_RFC5245) {
|
||||
type = PRFLX_PORT_TYPE;
|
||||
// RFC 5245 - The priority of the candidate is set to the PRIORITY
|
||||
// attribute from the request.
|
||||
const StunUInt32Attribute* priority_attr =
|
||||
stun_msg->GetUInt32(STUN_ATTR_PRIORITY);
|
||||
if (!priority_attr) {
|
||||
LOG(LS_WARNING) << "P2PTransportChannel::OnUnknownAddress - "
|
||||
<< "No STUN_ATTR_PRIORITY found in the "
|
||||
<< "STUN request message";
|
||||
ASSERT(false);
|
||||
return;
|
||||
}
|
||||
priority = priority_attr->value();
|
||||
} else {
|
||||
// G-ICE doesn't support prflx candidate.
|
||||
// We set candidate type to STUN_PORT_TYPE if the binding request comes
|
||||
@ -493,6 +505,7 @@ void P2PTransportChannel::OnUnknownAddress(
|
||||
port->Network()->name(), 0U,
|
||||
talk_base::ToString<uint32>(talk_base::ComputeCrc32(id)));
|
||||
new_remote_candidate.set_priority(
|
||||
(port->IceProtocol() == ICEPROTO_RFC5245) ? priority :
|
||||
new_remote_candidate.GetPriority(ICE_TYPE_PREFERENCE_SRFLX,
|
||||
port->Network()->preference()));
|
||||
}
|
||||
|
@ -40,8 +40,8 @@
|
||||
#include "talk/base/thread.h"
|
||||
#include "talk/base/virtualsocketserver.h"
|
||||
#include "talk/p2p/base/p2ptransportchannel.h"
|
||||
#include "talk/p2p/base/testrelayserver.h"
|
||||
#include "talk/p2p/base/teststunserver.h"
|
||||
#include "talk/p2p/base/testturnserver.h"
|
||||
#include "talk/p2p/client/basicportallocator.h"
|
||||
|
||||
using cricket::kDefaultPortAllocatorFlags;
|
||||
@ -87,12 +87,10 @@ static const SocketAddress kCascadedPrivateAddrs[2] =
|
||||
// The address of the public STUN server.
|
||||
static const SocketAddress kStunAddr("99.99.99.1", cricket::STUN_SERVER_PORT);
|
||||
// The addresses for the public relay server.
|
||||
static const SocketAddress kRelayUdpIntAddr("99.99.99.2", 5000);
|
||||
static const SocketAddress kRelayUdpExtAddr("99.99.99.3", 5001);
|
||||
static const SocketAddress kRelayTcpIntAddr("99.99.99.2", 5002);
|
||||
static const SocketAddress kRelayTcpExtAddr("99.99.99.3", 5003);
|
||||
static const SocketAddress kRelaySslTcpIntAddr("99.99.99.2", 5004);
|
||||
static const SocketAddress kRelaySslTcpExtAddr("99.99.99.3", 5005);
|
||||
static const SocketAddress kTurnUdpIntAddr("99.99.99.4",
|
||||
cricket::STUN_SERVER_PORT);
|
||||
static const SocketAddress kTurnUdpExtAddr("99.99.99.5", 0);
|
||||
static const cricket::RelayCredentials kRelayCredentials("test", "test");
|
||||
|
||||
// Based on ICE_UFRAG_LENGTH
|
||||
static const char* kIceUfrag[4] = {"TESTICEUFRAG0000", "TESTICEUFRAG0001",
|
||||
@ -133,22 +131,30 @@ class P2PTransportChannelTestBase : public testing::Test,
|
||||
ss_(new talk_base::FirewallSocketServer(nss_.get())),
|
||||
ss_scope_(ss_.get()),
|
||||
stun_server_(main_, kStunAddr),
|
||||
relay_server_(main_, kRelayUdpIntAddr, kRelayUdpExtAddr,
|
||||
kRelayTcpIntAddr, kRelayTcpExtAddr,
|
||||
kRelaySslTcpIntAddr, kRelaySslTcpExtAddr),
|
||||
turn_server_(main_, kTurnUdpIntAddr, kTurnUdpExtAddr),
|
||||
socks_server1_(ss_.get(), kSocksProxyAddrs[0],
|
||||
ss_.get(), kSocksProxyAddrs[0]),
|
||||
socks_server2_(ss_.get(), kSocksProxyAddrs[1],
|
||||
ss_.get(), kSocksProxyAddrs[1]),
|
||||
clear_remote_candidates_ufrag_pwd_(false) {
|
||||
clear_remote_candidates_ufrag_pwd_(false),
|
||||
force_relay_(false) {
|
||||
ep1_.role_ = cricket::ICEROLE_CONTROLLING;
|
||||
ep2_.role_ = cricket::ICEROLE_CONTROLLED;
|
||||
ep1_.allocator_.reset(new cricket::BasicPortAllocator(
|
||||
&ep1_.network_manager_, kStunAddr, kRelayUdpIntAddr,
|
||||
kRelayTcpIntAddr, kRelaySslTcpIntAddr));
|
||||
ep2_.allocator_.reset(new cricket::BasicPortAllocator(
|
||||
&ep2_.network_manager_, kStunAddr, kRelayUdpIntAddr,
|
||||
kRelayTcpIntAddr, kRelaySslTcpIntAddr));
|
||||
ep1_.allocator_.reset(
|
||||
new cricket::BasicPortAllocator(&ep1_.network_manager_,
|
||||
kStunAddr, talk_base::SocketAddress(), talk_base::SocketAddress(),
|
||||
talk_base::SocketAddress()));
|
||||
ep2_.allocator_.reset(
|
||||
new cricket::BasicPortAllocator(&ep2_.network_manager_,
|
||||
kStunAddr, talk_base::SocketAddress(), talk_base::SocketAddress(),
|
||||
talk_base::SocketAddress()));
|
||||
|
||||
cricket::RelayServerConfig relay_server(cricket::RELAY_TURN);
|
||||
relay_server.credentials = kRelayCredentials;
|
||||
relay_server.ports.push_back(cricket::ProtocolAddress(
|
||||
kTurnUdpIntAddr, cricket::PROTO_UDP, false));
|
||||
ep1_.allocator_->AddRelay(relay_server);
|
||||
ep2_.allocator_->AddRelay(relay_server);
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -238,7 +244,7 @@ class P2PTransportChannelTestBase : public testing::Test,
|
||||
}
|
||||
|
||||
talk_base::FakeNetworkManager network_manager_;
|
||||
talk_base::scoped_ptr<cricket::PortAllocator> allocator_;
|
||||
talk_base::scoped_ptr<cricket::BasicPortAllocator> allocator_;
|
||||
ChannelData cd1_;
|
||||
ChannelData cd2_;
|
||||
int signaling_delay_;
|
||||
@ -443,7 +449,6 @@ class P2PTransportChannelTestBase : public testing::Test,
|
||||
int32 converge_start = talk_base::Time(), converge_time;
|
||||
int converge_wait = 2000;
|
||||
EXPECT_TRUE_WAIT_MARGIN(
|
||||
LocalCandidate(ep1_ch1())->type() == expected.local_type &&
|
||||
LocalCandidate(ep1_ch1())->protocol() == expected.local_proto &&
|
||||
RemoteCandidate(ep1_ch1())->type() == expected.remote_type &&
|
||||
RemoteCandidate(ep1_ch1())->protocol() == expected.remote_proto,
|
||||
@ -451,7 +456,10 @@ class P2PTransportChannelTestBase : public testing::Test,
|
||||
converge_wait);
|
||||
|
||||
// Also do EXPECT_EQ on each part so that failures are more verbose.
|
||||
EXPECT_EQ(expected.local_type, LocalCandidate(ep1_ch1())->type());
|
||||
if (expected.local_type != LocalCandidate(ep1_ch1())->type()) {
|
||||
EXPECT_TRUE(expected.local_type == cricket::LOCAL_PORT_TYPE ||
|
||||
expected.local_type == cricket::PRFLX_PORT_TYPE);
|
||||
}
|
||||
EXPECT_EQ(expected.local_proto, LocalCandidate(ep1_ch1())->protocol());
|
||||
EXPECT_EQ(expected.remote_type, RemoteCandidate(ep1_ch1())->type());
|
||||
EXPECT_EQ(expected.remote_proto, RemoteCandidate(ep1_ch1())->protocol());
|
||||
@ -482,13 +490,14 @@ class P2PTransportChannelTestBase : public testing::Test,
|
||||
// i.e. when don't match its remote type is either local or stun.
|
||||
// TODO(ronghuawu): Refine the test criteria.
|
||||
// https://code.google.com/p/webrtc/issues/detail?id=1953
|
||||
if (expected.remote_type2 != RemoteCandidate(ep2_ch1())->type())
|
||||
if (expected.remote_type2 != RemoteCandidate(ep2_ch1())->type()) {
|
||||
EXPECT_TRUE(expected.remote_type2 == cricket::LOCAL_PORT_TYPE ||
|
||||
expected.remote_type2 == cricket::STUN_PORT_TYPE);
|
||||
EXPECT_TRUE(
|
||||
RemoteCandidate(ep2_ch1())->type() == cricket::LOCAL_PORT_TYPE ||
|
||||
RemoteCandidate(ep2_ch1())->type() == cricket::STUN_PORT_TYPE ||
|
||||
RemoteCandidate(ep2_ch1())->type() == cricket::PRFLX_PORT_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
converge_time = talk_base::TimeSince(converge_start);
|
||||
@ -638,6 +647,9 @@ class P2PTransportChannelTestBase : public testing::Test,
|
||||
// We pass the candidates directly to the other side.
|
||||
void OnCandidate(cricket::TransportChannelImpl* ch,
|
||||
const cricket::Candidate& c) {
|
||||
if (force_relay_ && c.type() != cricket::RELAY_PORT_TYPE)
|
||||
return;
|
||||
|
||||
main_->PostDelayed(GetEndpoint(ch)->signaling_delay_, this, 0,
|
||||
new CandidateData(ch, c));
|
||||
}
|
||||
@ -718,6 +730,10 @@ class P2PTransportChannelTestBase : public testing::Test,
|
||||
clear_remote_candidates_ufrag_pwd_ = clear;
|
||||
}
|
||||
|
||||
void set_force_relay(bool relay) {
|
||||
force_relay_ = relay;
|
||||
}
|
||||
|
||||
private:
|
||||
talk_base::Thread* main_;
|
||||
talk_base::scoped_ptr<talk_base::PhysicalSocketServer> pss_;
|
||||
@ -726,12 +742,13 @@ class P2PTransportChannelTestBase : public testing::Test,
|
||||
talk_base::scoped_ptr<talk_base::FirewallSocketServer> ss_;
|
||||
talk_base::SocketServerScope ss_scope_;
|
||||
cricket::TestStunServer stun_server_;
|
||||
cricket::TestRelayServer relay_server_;
|
||||
cricket::TestTurnServer turn_server_;
|
||||
talk_base::SocksProxyServer socks_server1_;
|
||||
talk_base::SocksProxyServer socks_server2_;
|
||||
Endpoint ep1_;
|
||||
Endpoint ep2_;
|
||||
bool clear_remote_candidates_ufrag_pwd_;
|
||||
bool force_relay_;
|
||||
};
|
||||
|
||||
// The tests have only a few outcomes, which we predefine.
|
||||
@ -1509,24 +1526,18 @@ TEST_F(P2PTransportChannelTest, TestIPv6Connections) {
|
||||
DestroyChannels();
|
||||
}
|
||||
|
||||
// Simple test without any stun or turn server addresses. Making sure ports
|
||||
// can receive and send data.
|
||||
TEST_F(P2PTransportChannelTest, TestSharedSocketModeWithStunTurnAddress) {
|
||||
AddAddress(0, kPublicAddrs[0]);
|
||||
AddAddress(1, kPublicAddrs[1]);
|
||||
|
||||
const talk_base::SocketAddress null_addr;
|
||||
GetEndpoint(0)->allocator_.reset(new cricket::BasicPortAllocator(
|
||||
&(GetEndpoint(0)->network_manager_), null_addr, null_addr,
|
||||
null_addr, null_addr));
|
||||
GetEndpoint(1)->allocator_.reset(new cricket::BasicPortAllocator(
|
||||
&(GetEndpoint(1)->network_manager_), null_addr, null_addr,
|
||||
null_addr, null_addr));
|
||||
|
||||
SetAllocatorFlags(0, cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET |
|
||||
cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG);
|
||||
SetAllocatorFlags(1, cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET |
|
||||
cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG);
|
||||
// Testing forceful TURN connections.
|
||||
TEST_F(P2PTransportChannelTest, TestForceTurn) {
|
||||
ConfigureEndpoints(NAT_PORT_RESTRICTED, NAT_SYMMETRIC,
|
||||
kDefaultPortAllocatorFlags |
|
||||
cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET |
|
||||
cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG,
|
||||
kDefaultPortAllocatorFlags |
|
||||
cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET |
|
||||
cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG,
|
||||
kDefaultStepDelay, kDefaultStepDelay,
|
||||
cricket::ICEPROTO_RFC5245);
|
||||
set_force_relay(true);
|
||||
|
||||
SetAllocationStepDelay(0, kMinimumStepDelay);
|
||||
SetAllocationStepDelay(1, kMinimumStepDelay);
|
||||
@ -1542,6 +1553,11 @@ TEST_F(P2PTransportChannelTest, TestSharedSocketModeWithStunTurnAddress) {
|
||||
EXPECT_TRUE(ep1_ch1()->best_connection() &&
|
||||
ep2_ch1()->best_connection());
|
||||
|
||||
EXPECT_EQ(cricket::RELAY_PORT_TYPE, RemoteCandidate(ep1_ch1())->type());
|
||||
EXPECT_EQ(cricket::RELAY_PORT_TYPE, LocalCandidate(ep1_ch1())->type());
|
||||
EXPECT_EQ(cricket::RELAY_PORT_TYPE, RemoteCandidate(ep2_ch1())->type());
|
||||
EXPECT_EQ(cricket::RELAY_PORT_TYPE, LocalCandidate(ep2_ch1())->type());
|
||||
|
||||
TestSendRecv(1);
|
||||
DestroyChannels();
|
||||
}
|
||||
|
@ -2178,23 +2178,21 @@ TEST_F(PortTest, TestCandidateFoundation) {
|
||||
talk_base::scoped_ptr<Port> turnport1(CreateTurnPort(
|
||||
kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP));
|
||||
turnport1->PrepareAddress();
|
||||
ASSERT_EQ_WAIT(2U, turnport1->Candidates().size(), kTimeout);
|
||||
EXPECT_NE(turnport1->Candidates()[0].foundation(),
|
||||
turnport1->Candidates()[1].foundation());
|
||||
ASSERT_EQ_WAIT(1U, turnport1->Candidates().size(), kTimeout);
|
||||
EXPECT_NE(udpport1->Candidates()[0].foundation(),
|
||||
turnport1->Candidates()[1].foundation());
|
||||
turnport1->Candidates()[0].foundation());
|
||||
EXPECT_NE(udpport2->Candidates()[0].foundation(),
|
||||
turnport1->Candidates()[1].foundation());
|
||||
turnport1->Candidates()[0].foundation());
|
||||
EXPECT_NE(stunport->Candidates()[0].foundation(),
|
||||
turnport1->Candidates()[0].foundation());
|
||||
EXPECT_NE(stunport->Candidates()[0].foundation(),
|
||||
turnport1->Candidates()[1].foundation());
|
||||
EXPECT_EQ(stunport->Candidates()[0].foundation(),
|
||||
turnport1->Candidates()[0].foundation());
|
||||
talk_base::scoped_ptr<Port> turnport2(CreateTurnPort(
|
||||
kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP));
|
||||
turnport2->PrepareAddress();
|
||||
ASSERT_EQ_WAIT(2U, turnport2->Candidates().size(), kTimeout);
|
||||
EXPECT_EQ(turnport1->Candidates()[1].foundation(),
|
||||
turnport2->Candidates()[1].foundation());
|
||||
ASSERT_EQ_WAIT(1U, turnport2->Candidates().size(), kTimeout);
|
||||
EXPECT_EQ(turnport1->Candidates()[0].foundation(),
|
||||
turnport2->Candidates()[0].foundation());
|
||||
|
||||
// Running a second turn server, to get different base IP address.
|
||||
SocketAddress kTurnUdpIntAddr2("99.99.98.4", STUN_SERVER_PORT);
|
||||
@ -2205,9 +2203,9 @@ TEST_F(PortTest, TestCandidateFoundation) {
|
||||
kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP,
|
||||
kTurnUdpIntAddr2));
|
||||
turnport3->PrepareAddress();
|
||||
ASSERT_EQ_WAIT(2U, turnport3->Candidates().size(), kTimeout);
|
||||
EXPECT_NE(turnport3->Candidates()[1].foundation(),
|
||||
turnport2->Candidates()[1].foundation());
|
||||
ASSERT_EQ_WAIT(1U, turnport3->Candidates().size(), kTimeout);
|
||||
EXPECT_NE(turnport3->Candidates()[0].foundation(),
|
||||
turnport2->Candidates()[0].foundation());
|
||||
}
|
||||
|
||||
// This test verifies the related addresses of different types of
|
||||
@ -2249,13 +2247,11 @@ TEST_F(PortTest, TestCandidateRelatedAddress) {
|
||||
talk_base::scoped_ptr<Port> turnport(CreateTurnPort(
|
||||
kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP));
|
||||
turnport->PrepareAddress();
|
||||
ASSERT_EQ_WAIT(2U, turnport->Candidates().size(), kTimeout);
|
||||
ASSERT_EQ_WAIT(1U, turnport->Candidates().size(), kTimeout);
|
||||
EXPECT_EQ(kTurnUdpExtAddr.ipaddr(),
|
||||
turnport->Candidates()[1].address().ipaddr());
|
||||
EXPECT_EQ(kLocalAddr1.ipaddr(),
|
||||
turnport->Candidates()[0].related_address().ipaddr());
|
||||
turnport->Candidates()[0].address().ipaddr());
|
||||
EXPECT_EQ(kNatAddr1.ipaddr(),
|
||||
turnport->Candidates()[1].related_address().ipaddr());
|
||||
turnport->Candidates()[0].related_address().ipaddr());
|
||||
}
|
||||
|
||||
// Test priority value overflow handling when preference is set to 3.
|
||||
|
@ -192,7 +192,7 @@ void UDPPort::MaybePrepareStunCandidate() {
|
||||
if (!server_addr_.IsNil()) {
|
||||
SendStunBindingRequest();
|
||||
} else {
|
||||
// Processing host candidate address.
|
||||
// Port is done allocating candidates.
|
||||
SetResult(true);
|
||||
}
|
||||
}
|
||||
|
@ -142,7 +142,6 @@ class UDPPort : public Port {
|
||||
|
||||
void SendStunBindingRequest();
|
||||
|
||||
|
||||
private:
|
||||
// DNS resolution of the STUN server.
|
||||
void ResolveStunAddress();
|
||||
|
@ -480,22 +480,19 @@ void TurnPort::OnSendStunPacket(const void* data, size_t size,
|
||||
}
|
||||
|
||||
void TurnPort::OnStunAddress(const talk_base::SocketAddress& address) {
|
||||
if (server_address_.proto == PROTO_UDP &&
|
||||
address != socket_->GetLocalAddress()) {
|
||||
AddAddress(address, // Candidate address.
|
||||
socket_->GetLocalAddress(), // Base address.
|
||||
socket_->GetLocalAddress(), // Related address.
|
||||
UDP_PROTOCOL_NAME,
|
||||
STUN_PORT_TYPE,
|
||||
ICE_TYPE_PREFERENCE_SRFLX,
|
||||
false);
|
||||
}
|
||||
// STUN Port will discover STUN candidate, as it's supplied with first TURN
|
||||
// server address.
|
||||
// Why not using this address? - P2PTransportChannel will start creating
|
||||
// connections after first candidate, which means it could start creating the
|
||||
// connections before TURN candidate added. For that to handle, we need to
|
||||
// supply STUN candidate from this port to UDPPort, and TurnPort should have
|
||||
// handle to UDPPort to pass back the address.
|
||||
}
|
||||
|
||||
void TurnPort::OnAllocateSuccess(const talk_base::SocketAddress& address,
|
||||
const talk_base::SocketAddress& stun_address) {
|
||||
// For relayed candidate, Base is the candidate itself.
|
||||
connected_ = true;
|
||||
// For relayed candidate, Base is the candidate itself.
|
||||
AddAddress(address, // Candidate address.
|
||||
address, // Base address.
|
||||
stun_address, // Related address.
|
||||
@ -746,7 +743,6 @@ void TurnAllocateRequest::OnResponse(StunMessage* response) {
|
||||
<< "attribute in allocate success response";
|
||||
return;
|
||||
}
|
||||
|
||||
// Using XOR-Mapped-Address for stun.
|
||||
port_->OnStunAddress(mapped_attr->GetAddress());
|
||||
|
||||
|
@ -57,8 +57,8 @@ class TurnPort : public Port {
|
||||
const std::string& password, // ice password.
|
||||
const ProtocolAddress& server_address,
|
||||
const RelayCredentials& credentials) {
|
||||
return new TurnPort(thread, factory, network, socket, username, password,
|
||||
server_address, credentials);
|
||||
return new TurnPort(thread, factory, network, socket,
|
||||
username, password, server_address, credentials);
|
||||
}
|
||||
|
||||
static TurnPort* Create(talk_base::Thread* thread,
|
||||
|
@ -206,8 +206,8 @@ class TurnPortTest : public testing::Test,
|
||||
|
||||
cricket::RelayCredentials credentials(username, password);
|
||||
turn_port_.reset(cricket::TurnPort::Create(
|
||||
main_, &socket_factory_, &network_, socket_.get(), kIceUfrag1, kIcePwd1,
|
||||
server_address, credentials));
|
||||
main_, &socket_factory_, &network_, socket_.get(),
|
||||
kIceUfrag1, kIcePwd1, server_address, credentials));
|
||||
// Set ICE protocol type to ICEPROTO_RFC5245, as port by default will be
|
||||
// in Hybrid mode. Protocol type is necessary to send correct type STUN ping
|
||||
// messages.
|
||||
|
@ -161,7 +161,7 @@ class AllocationSequence : public talk_base::MessageHandler,
|
||||
ProtocolList protocols_;
|
||||
talk_base::scoped_ptr<talk_base::AsyncPacketSocket> udp_socket_;
|
||||
// There will be only one udp port per AllocationSequence.
|
||||
Port* udp_port_;
|
||||
UDPPort* udp_port_;
|
||||
// Keeping a map for turn ports keyed with server addresses.
|
||||
std::map<talk_base::SocketAddress, Port*> turn_ports_;
|
||||
int phase_;
|
||||
@ -206,13 +206,15 @@ BasicPortAllocator::BasicPortAllocator(
|
||||
stun_address_(stun_address) {
|
||||
|
||||
RelayServerConfig config(RELAY_GTURN);
|
||||
if (!relay_address_udp.IsAny())
|
||||
if (!relay_address_udp.IsAny() && !relay_address_udp.IsNil())
|
||||
config.ports.push_back(ProtocolAddress(relay_address_udp, PROTO_UDP));
|
||||
if (!relay_address_tcp.IsAny())
|
||||
if (!relay_address_tcp.IsAny() && !relay_address_tcp.IsNil())
|
||||
config.ports.push_back(ProtocolAddress(relay_address_tcp, PROTO_TCP));
|
||||
if (!relay_address_ssl.IsAny())
|
||||
if (!relay_address_ssl.IsAny() && !relay_address_ssl.IsNil())
|
||||
config.ports.push_back(ProtocolAddress(relay_address_ssl, PROTO_SSLTCP));
|
||||
AddRelay(config);
|
||||
|
||||
if (!config.ports.empty())
|
||||
AddRelay(config);
|
||||
|
||||
Construct();
|
||||
}
|
||||
@ -868,13 +870,18 @@ void AllocationSequence::CreateUDPPorts() {
|
||||
|
||||
// If STUN is not disabled, setting stun server address to port.
|
||||
if (!IsFlagSet(PORTALLOCATOR_DISABLE_STUN)) {
|
||||
// If there is a TURN UDP server available, then we will use TURN port
|
||||
// to get stun address, otherwise by UDP port.
|
||||
// Shared socket mode is not used in GTURN mode.
|
||||
if (config_ &&
|
||||
!config_->SupportsProtocol(RELAY_TURN, PROTO_UDP) &&
|
||||
!config_->stun_address.IsNil()) {
|
||||
// If config has stun_address, use it to get server reflexive candidate
|
||||
// otherwise use first TURN server which supports UDP.
|
||||
if (config_ && !config_->stun_address.IsNil()) {
|
||||
LOG(LS_INFO) << "AllocationSequence: UDPPort will be handling the "
|
||||
<< "STUN candidate generation.";
|
||||
port->set_server_addr(config_->stun_address);
|
||||
} else if (config_ &&
|
||||
config_->SupportsProtocol(RELAY_TURN, PROTO_UDP)) {
|
||||
port->set_server_addr(config_->GetFirstRelayServerAddress(
|
||||
RELAY_TURN, PROTO_UDP));
|
||||
LOG(LS_INFO) << "AllocationSequence: TURN Server address will be "
|
||||
<< " used for generating STUN candidate.";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -911,8 +918,6 @@ void AllocationSequence::CreateStunPorts() {
|
||||
}
|
||||
|
||||
if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET)) {
|
||||
LOG(LS_INFO) << "AllocationSequence: "
|
||||
<< "UDPPort will be handling the STUN candidate generation.";
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1118,7 +1123,7 @@ bool PortConfiguration::SupportsProtocol(
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PortConfiguration::SupportsProtocol(const RelayType turn_type,
|
||||
bool PortConfiguration::SupportsProtocol(RelayType turn_type,
|
||||
ProtocolType type) const {
|
||||
for (size_t i = 0; i < relays.size(); ++i) {
|
||||
if (relays[i].type == turn_type &&
|
||||
@ -1128,4 +1133,14 @@ bool PortConfiguration::SupportsProtocol(const RelayType turn_type,
|
||||
return false;
|
||||
}
|
||||
|
||||
talk_base::SocketAddress PortConfiguration::GetFirstRelayServerAddress(
|
||||
RelayType turn_type, ProtocolType type) const {
|
||||
for (size_t i = 0; i < relays.size(); ++i) {
|
||||
if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) {
|
||||
return relays[i].ports.front().address;
|
||||
}
|
||||
}
|
||||
return talk_base::SocketAddress();
|
||||
}
|
||||
|
||||
} // namespace cricket
|
||||
|
@ -234,7 +234,11 @@ struct PortConfiguration : public talk_base::MessageData {
|
||||
// Determines whether the given relay server supports the given protocol.
|
||||
bool SupportsProtocol(const RelayServerConfig& relay,
|
||||
ProtocolType type) const;
|
||||
bool SupportsProtocol(const RelayType turn_type, ProtocolType type) const;
|
||||
bool SupportsProtocol(RelayType turn_type, ProtocolType type) const;
|
||||
// Helper method returns the first server address for the matching
|
||||
// RelayType and Protocol type.
|
||||
talk_base::SocketAddress GetFirstRelayServerAddress(
|
||||
RelayType turn_type, ProtocolType type) const;
|
||||
};
|
||||
|
||||
} // namespace cricket
|
||||
|
@ -804,9 +804,8 @@ TEST_F(PortAllocatorTest, TestSharedSocketWithNatUsingTurn) {
|
||||
EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout);
|
||||
EXPECT_EQ(3U, candidates_.size());
|
||||
// Local port will be created first and then TURN port.
|
||||
// Checking TURN port has two candidates, STUN + TURN.
|
||||
EXPECT_EQ(1U, ports_[0]->Candidates().size());
|
||||
EXPECT_EQ(2U, ports_[1]->Candidates().size());
|
||||
EXPECT_EQ(2U, ports_[0]->Candidates().size());
|
||||
EXPECT_EQ(1U, ports_[1]->Candidates().size());
|
||||
}
|
||||
|
||||
// This test verifies when PORTALLOCATOR_ENABLE_SHARED_SOCKET flag is enabled
|
||||
|
Loading…
x
Reference in New Issue
Block a user