diff --git a/talk/p2p/base/p2ptransportchannel.cc b/talk/p2p/base/p2ptransportchannel.cc index 277f286d9c..e7f9d45f02 100644 --- a/talk/p2p/base/p2ptransportchannel.cc +++ b/talk/p2p/base/p2ptransportchannel.cc @@ -470,22 +470,10 @@ 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 @@ -505,7 +493,6 @@ void P2PTransportChannel::OnUnknownAddress( port->Network()->name(), 0U, talk_base::ToString(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())); } diff --git a/talk/p2p/base/p2ptransportchannel_unittest.cc b/talk/p2p/base/p2ptransportchannel_unittest.cc index 0a75da4e84..c59a342377 100644 --- a/talk/p2p/base/p2ptransportchannel_unittest.cc +++ b/talk/p2p/base/p2ptransportchannel_unittest.cc @@ -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,10 +87,12 @@ 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 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"); +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); // Based on ICE_UFRAG_LENGTH static const char* kIceUfrag[4] = {"TESTICEUFRAG0000", "TESTICEUFRAG0001", @@ -131,30 +133,22 @@ class P2PTransportChannelTestBase : public testing::Test, ss_(new talk_base::FirewallSocketServer(nss_.get())), ss_scope_(ss_.get()), stun_server_(main_, kStunAddr), - turn_server_(main_, kTurnUdpIntAddr, kTurnUdpExtAddr), + relay_server_(main_, kRelayUdpIntAddr, kRelayUdpExtAddr, + kRelayTcpIntAddr, kRelayTcpExtAddr, + kRelaySslTcpIntAddr, kRelaySslTcpExtAddr), 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), - force_relay_(false) { + clear_remote_candidates_ufrag_pwd_(false) { ep1_.role_ = cricket::ICEROLE_CONTROLLING; ep2_.role_ = cricket::ICEROLE_CONTROLLED; - 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); + 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)); } protected: @@ -244,7 +238,7 @@ class P2PTransportChannelTestBase : public testing::Test, } talk_base::FakeNetworkManager network_manager_; - talk_base::scoped_ptr allocator_; + talk_base::scoped_ptr allocator_; ChannelData cd1_; ChannelData cd2_; int signaling_delay_; @@ -449,6 +443,7 @@ 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, @@ -456,10 +451,7 @@ class P2PTransportChannelTestBase : public testing::Test, converge_wait); // Also do EXPECT_EQ on each part so that failures are more verbose. - 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_type, LocalCandidate(ep1_ch1())->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()); @@ -490,14 +482,13 @@ 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); @@ -647,9 +638,6 @@ 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)); } @@ -730,10 +718,6 @@ 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 pss_; @@ -742,13 +726,12 @@ class P2PTransportChannelTestBase : public testing::Test, talk_base::scoped_ptr ss_; talk_base::SocketServerScope ss_scope_; cricket::TestStunServer stun_server_; - cricket::TestTurnServer turn_server_; + cricket::TestRelayServer relay_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. @@ -1526,18 +1509,24 @@ TEST_F(P2PTransportChannelTest, TestIPv6Connections) { DestroyChannels(); } -// 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); +// 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); SetAllocationStepDelay(0, kMinimumStepDelay); SetAllocationStepDelay(1, kMinimumStepDelay); @@ -1553,11 +1542,6 @@ TEST_F(P2PTransportChannelTest, TestForceTurn) { 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(); } diff --git a/talk/p2p/base/port_unittest.cc b/talk/p2p/base/port_unittest.cc index bb4d79b142..d96861c4e5 100644 --- a/talk/p2p/base/port_unittest.cc +++ b/talk/p2p/base/port_unittest.cc @@ -2178,21 +2178,23 @@ TEST_F(PortTest, TestCandidateFoundation) { talk_base::scoped_ptr turnport1(CreateTurnPort( kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); turnport1->PrepareAddress(); - ASSERT_EQ_WAIT(1U, turnport1->Candidates().size(), kTimeout); + ASSERT_EQ_WAIT(2U, turnport1->Candidates().size(), kTimeout); + EXPECT_NE(turnport1->Candidates()[0].foundation(), + turnport1->Candidates()[1].foundation()); EXPECT_NE(udpport1->Candidates()[0].foundation(), - turnport1->Candidates()[0].foundation()); + turnport1->Candidates()[1].foundation()); EXPECT_NE(udpport2->Candidates()[0].foundation(), - turnport1->Candidates()[0].foundation()); - EXPECT_NE(stunport->Candidates()[0].foundation(), - turnport1->Candidates()[0].foundation()); + turnport1->Candidates()[1].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 turnport2(CreateTurnPort( kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); turnport2->PrepareAddress(); - ASSERT_EQ_WAIT(1U, turnport2->Candidates().size(), kTimeout); - EXPECT_EQ(turnport1->Candidates()[0].foundation(), - turnport2->Candidates()[0].foundation()); + ASSERT_EQ_WAIT(2U, turnport2->Candidates().size(), kTimeout); + EXPECT_EQ(turnport1->Candidates()[1].foundation(), + turnport2->Candidates()[1].foundation()); // Running a second turn server, to get different base IP address. SocketAddress kTurnUdpIntAddr2("99.99.98.4", STUN_SERVER_PORT); @@ -2203,9 +2205,9 @@ TEST_F(PortTest, TestCandidateFoundation) { kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP, kTurnUdpIntAddr2)); turnport3->PrepareAddress(); - ASSERT_EQ_WAIT(1U, turnport3->Candidates().size(), kTimeout); - EXPECT_NE(turnport3->Candidates()[0].foundation(), - turnport2->Candidates()[0].foundation()); + ASSERT_EQ_WAIT(2U, turnport3->Candidates().size(), kTimeout); + EXPECT_NE(turnport3->Candidates()[1].foundation(), + turnport2->Candidates()[1].foundation()); } // This test verifies the related addresses of different types of @@ -2247,11 +2249,13 @@ TEST_F(PortTest, TestCandidateRelatedAddress) { talk_base::scoped_ptr turnport(CreateTurnPort( kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); turnport->PrepareAddress(); - ASSERT_EQ_WAIT(1U, turnport->Candidates().size(), kTimeout); + ASSERT_EQ_WAIT(2U, turnport->Candidates().size(), kTimeout); EXPECT_EQ(kTurnUdpExtAddr.ipaddr(), - turnport->Candidates()[0].address().ipaddr()); - EXPECT_EQ(kNatAddr1.ipaddr(), + turnport->Candidates()[1].address().ipaddr()); + EXPECT_EQ(kLocalAddr1.ipaddr(), turnport->Candidates()[0].related_address().ipaddr()); + EXPECT_EQ(kNatAddr1.ipaddr(), + turnport->Candidates()[1].related_address().ipaddr()); } // Test priority value overflow handling when preference is set to 3. diff --git a/talk/p2p/base/stunport.cc b/talk/p2p/base/stunport.cc index 6e18fc5056..e9a2bb9805 100644 --- a/talk/p2p/base/stunport.cc +++ b/talk/p2p/base/stunport.cc @@ -192,7 +192,7 @@ void UDPPort::MaybePrepareStunCandidate() { if (!server_addr_.IsNil()) { SendStunBindingRequest(); } else { - // Port is done allocating candidates. + // Processing host candidate address. SetResult(true); } } diff --git a/talk/p2p/base/stunport.h b/talk/p2p/base/stunport.h index c45d6af334..1612c97bc5 100644 --- a/talk/p2p/base/stunport.h +++ b/talk/p2p/base/stunport.h @@ -142,6 +142,7 @@ class UDPPort : public Port { void SendStunBindingRequest(); + private: // DNS resolution of the STUN server. void ResolveStunAddress(); diff --git a/talk/p2p/base/turnport.cc b/talk/p2p/base/turnport.cc index d293845fe5..c552d73f79 100644 --- a/talk/p2p/base/turnport.cc +++ b/talk/p2p/base/turnport.cc @@ -480,19 +480,22 @@ void TurnPort::OnSendStunPacket(const void* data, size_t size, } void TurnPort::OnStunAddress(const talk_base::SocketAddress& address) { - // 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. + 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); + } } void TurnPort::OnAllocateSuccess(const talk_base::SocketAddress& address, const talk_base::SocketAddress& stun_address) { - connected_ = true; // For relayed candidate, Base is the candidate itself. + connected_ = true; AddAddress(address, // Candidate address. address, // Base address. stun_address, // Related address. @@ -743,6 +746,7 @@ void TurnAllocateRequest::OnResponse(StunMessage* response) { << "attribute in allocate success response"; return; } + // Using XOR-Mapped-Address for stun. port_->OnStunAddress(mapped_attr->GetAddress()); diff --git a/talk/p2p/base/turnport.h b/talk/p2p/base/turnport.h index 2f5e8c4ab1..4745b33ee4 100644 --- a/talk/p2p/base/turnport.h +++ b/talk/p2p/base/turnport.h @@ -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, diff --git a/talk/p2p/base/turnport_unittest.cc b/talk/p2p/base/turnport_unittest.cc index 12a19aa4db..3b51ebbf83 100644 --- a/talk/p2p/base/turnport_unittest.cc +++ b/talk/p2p/base/turnport_unittest.cc @@ -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. diff --git a/talk/p2p/client/basicportallocator.cc b/talk/p2p/client/basicportallocator.cc index c801be275c..12d70a3575 100644 --- a/talk/p2p/client/basicportallocator.cc +++ b/talk/p2p/client/basicportallocator.cc @@ -161,7 +161,7 @@ class AllocationSequence : public talk_base::MessageHandler, ProtocolList protocols_; talk_base::scoped_ptr udp_socket_; // There will be only one udp port per AllocationSequence. - UDPPort* udp_port_; + Port* udp_port_; // Keeping a map for turn ports keyed with server addresses. std::map turn_ports_; int phase_; @@ -206,15 +206,13 @@ BasicPortAllocator::BasicPortAllocator( stun_address_(stun_address) { RelayServerConfig config(RELAY_GTURN); - if (!relay_address_udp.IsAny() && !relay_address_udp.IsNil()) + if (!relay_address_udp.IsAny()) config.ports.push_back(ProtocolAddress(relay_address_udp, PROTO_UDP)); - if (!relay_address_tcp.IsAny() && !relay_address_tcp.IsNil()) + if (!relay_address_tcp.IsAny()) config.ports.push_back(ProtocolAddress(relay_address_tcp, PROTO_TCP)); - if (!relay_address_ssl.IsAny() && !relay_address_ssl.IsNil()) + if (!relay_address_ssl.IsAny()) config.ports.push_back(ProtocolAddress(relay_address_ssl, PROTO_SSLTCP)); - - if (!config.ports.empty()) - AddRelay(config); + AddRelay(config); Construct(); } @@ -870,18 +868,13 @@ void AllocationSequence::CreateUDPPorts() { // If STUN is not disabled, setting stun server address to port. if (!IsFlagSet(PORTALLOCATOR_DISABLE_STUN)) { - // 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."; + // 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()) { 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."; } } } @@ -918,6 +911,8 @@ void AllocationSequence::CreateStunPorts() { } if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET)) { + LOG(LS_INFO) << "AllocationSequence: " + << "UDPPort will be handling the STUN candidate generation."; return; } @@ -1123,7 +1118,7 @@ bool PortConfiguration::SupportsProtocol( return false; } -bool PortConfiguration::SupportsProtocol(RelayType turn_type, +bool PortConfiguration::SupportsProtocol(const RelayType turn_type, ProtocolType type) const { for (size_t i = 0; i < relays.size(); ++i) { if (relays[i].type == turn_type && @@ -1133,14 +1128,4 @@ bool PortConfiguration::SupportsProtocol(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 diff --git a/talk/p2p/client/basicportallocator.h b/talk/p2p/client/basicportallocator.h index 8a60c425ca..b8660f0a34 100644 --- a/talk/p2p/client/basicportallocator.h +++ b/talk/p2p/client/basicportallocator.h @@ -234,11 +234,7 @@ 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(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; + bool SupportsProtocol(const RelayType turn_type, ProtocolType type) const; }; } // namespace cricket diff --git a/talk/p2p/client/portallocator_unittest.cc b/talk/p2p/client/portallocator_unittest.cc index 44a8f2725d..1f027e8698 100644 --- a/talk/p2p/client/portallocator_unittest.cc +++ b/talk/p2p/client/portallocator_unittest.cc @@ -804,8 +804,9 @@ 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. - EXPECT_EQ(2U, ports_[0]->Candidates().size()); - EXPECT_EQ(1U, ports_[1]->Candidates().size()); + // Checking TURN port has two candidates, STUN + TURN. + EXPECT_EQ(1U, ports_[0]->Candidates().size()); + EXPECT_EQ(2U, ports_[1]->Candidates().size()); } // This test verifies when PORTALLOCATOR_ENABLE_SHARED_SOCKET flag is enabled