summaryrefslogtreecommitdiff
path: root/p2p
diff options
context:
space:
mode:
authorbuildbot@webrtc.org <buildbot@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d>2014-05-13 22:58:27 +0000
committerbuildbot@webrtc.org <buildbot@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d>2014-05-13 22:58:27 +0000
commitba4b69f4755d1bfb1a956f390cb3ce2713189cf2 (patch)
tree11ccd61778efb20411919f746f9311f43ce97209 /p2p
parentb694da5277ab6c616cf46d3dee2fdd1da21d9228 (diff)
downloadtalk-ba4b69f4755d1bfb1a956f390cb3ce2713189cf2.tar.gz
(Auto)update libjingle 66924241-> 66927231
git-svn-id: http://webrtc.googlecode.com/svn/trunk/talk@6134 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'p2p')
-rw-r--r--p2p/base/p2ptransportchannel.cc1
-rw-r--r--p2p/base/p2ptransportchannel_unittest.cc89
-rw-r--r--p2p/base/port_unittest.cc30
-rw-r--r--p2p/base/stunport.cc2
-rw-r--r--p2p/base/stunport.h1
-rw-r--r--p2p/base/turnport.cc20
-rw-r--r--p2p/base/turnport.h4
-rw-r--r--p2p/base/turnport_unittest.cc4
-rw-r--r--p2p/client/basicportallocator.cc43
-rw-r--r--p2p/client/basicportallocator.h6
-rw-r--r--p2p/client/portallocator_unittest.cc5
11 files changed, 129 insertions, 76 deletions
diff --git a/p2p/base/p2ptransportchannel.cc b/p2p/base/p2ptransportchannel.cc
index e7f9d45..887fc45 100644
--- a/p2p/base/p2ptransportchannel.cc
+++ b/p2p/base/p2ptransportchannel.cc
@@ -470,7 +470,6 @@ void P2PTransportChannel::OnUnknownAddress(
}
} else {
// Create a new candidate with this address.
-
std::string type;
if (port->IceProtocol() == ICEPROTO_RFC5245) {
type = PRFLX_PORT_TYPE;
diff --git a/p2p/base/p2ptransportchannel_unittest.cc b/p2p/base/p2ptransportchannel_unittest.cc
index c59a342..fe22cb3 100644
--- a/p2p/base/p2ptransportchannel_unittest.cc
+++ b/p2p/base/p2ptransportchannel_unittest.cc
@@ -42,6 +42,7 @@
#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;
@@ -93,6 +94,11 @@ 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);
+// The addresses for the public turn 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");
// Based on ICE_UFRAG_LENGTH
static const char* kIceUfrag[4] = {"TESTICEUFRAG0000", "TESTICEUFRAG0001",
@@ -133,6 +139,7 @@ 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),
@@ -140,9 +147,11 @@ class P2PTransportChannelTestBase : public testing::Test,
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));
@@ -238,7 +247,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_;
@@ -482,13 +491,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 +648,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 +731,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 +743,14 @@ class P2PTransportChannelTestBase : public testing::Test,
talk_base::scoped_ptr<talk_base::FirewallSocketServer> 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.
@@ -784,6 +803,35 @@ class P2PTransportChannelTest : public P2PTransportChannelTestBase {
int allocator_flags1, int allocator_flags2,
int delay1, int delay2,
cricket::IceProtocolType type) {
+ // Ideally we want to use TURN server for both GICE and ICE, but in case
+ // of GICE, TURN server usage is not producing results reliabally.
+ // TODO(mallinath): Remove Relay and use TURN server for all tests.
+ GetEndpoint(0)->allocator_.reset(
+ new cricket::BasicPortAllocator(&(GetEndpoint(0)->network_manager_),
+ kStunAddr, talk_base::SocketAddress(), talk_base::SocketAddress(),
+ talk_base::SocketAddress()));
+ GetEndpoint(1)->allocator_.reset(
+ new cricket::BasicPortAllocator(&(GetEndpoint(1)->network_manager_),
+ kStunAddr, talk_base::SocketAddress(), talk_base::SocketAddress(),
+ talk_base::SocketAddress()));
+
+ cricket::RelayServerConfig relay_server(cricket::RELAY_GTURN);
+ if (type == cricket::ICEPROTO_RFC5245) {
+ relay_server.type = cricket::RELAY_TURN;
+ relay_server.credentials = kRelayCredentials;
+ relay_server.ports.push_back(cricket::ProtocolAddress(
+ kTurnUdpIntAddr, cricket::PROTO_UDP, false));
+ } else {
+ relay_server.ports.push_back(cricket::ProtocolAddress(
+ kRelayUdpIntAddr, cricket::PROTO_UDP, false));
+ relay_server.ports.push_back(cricket::ProtocolAddress(
+ kRelayTcpIntAddr, cricket::PROTO_TCP, false));
+ relay_server.ports.push_back(cricket::ProtocolAddress(
+ kRelaySslTcpIntAddr, cricket::PROTO_SSLTCP, false));
+ }
+ GetEndpoint(0)->allocator_->AddRelay(relay_server);
+ GetEndpoint(1)->allocator_->AddRelay(relay_server);
+
ConfigureEndpoint(0, config1);
SetIceProtocol(0, type);
SetAllocatorFlags(0, allocator_flags1);
@@ -1509,24 +1557,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 +1584,11 @@ TEST_F(P2PTransportChannelTest, TestSharedSocketModeWithStunTurnAddress) {
EXPECT_TRUE(ep1_ch1()->best_connection() &&
ep2_ch1()->best_connection());
+ EXPECT_EQ("relay", RemoteCandidate(ep1_ch1())->type());
+ EXPECT_EQ("relay", LocalCandidate(ep1_ch1())->type());
+ EXPECT_EQ("relay", RemoteCandidate(ep2_ch1())->type());
+ EXPECT_EQ("relay", LocalCandidate(ep2_ch1())->type());
+
TestSendRecv(1);
DestroyChannels();
}
diff --git a/p2p/base/port_unittest.cc b/p2p/base/port_unittest.cc
index d96861c..804b61e 100644
--- a/p2p/base/port_unittest.cc
+++ b/p2p/base/port_unittest.cc
@@ -2178,23 +2178,19 @@ 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()[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 +2201,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 +2245,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.
diff --git a/p2p/base/stunport.cc b/p2p/base/stunport.cc
index e9a2bb9..6e18fc5 100644
--- a/p2p/base/stunport.cc
+++ b/p2p/base/stunport.cc
@@ -192,7 +192,7 @@ void UDPPort::MaybePrepareStunCandidate() {
if (!server_addr_.IsNil()) {
SendStunBindingRequest();
} else {
- // Processing host candidate address.
+ // Port is done allocating candidates.
SetResult(true);
}
}
diff --git a/p2p/base/stunport.h b/p2p/base/stunport.h
index 1612c97..c45d6af 100644
--- a/p2p/base/stunport.h
+++ b/p2p/base/stunport.h
@@ -142,7 +142,6 @@ class UDPPort : public Port {
void SendStunBindingRequest();
-
private:
// DNS resolution of the STUN server.
void ResolveStunAddress();
diff --git a/p2p/base/turnport.cc b/p2p/base/turnport.cc
index c552d73..d293845 100644
--- a/p2p/base/turnport.cc
+++ b/p2p/base/turnport.cc
@@ -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());
diff --git a/p2p/base/turnport.h b/p2p/base/turnport.h
index 4745b33..2f5e8c4 100644
--- a/p2p/base/turnport.h
+++ b/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/p2p/base/turnport_unittest.cc b/p2p/base/turnport_unittest.cc
index 3b51ebb..12a19aa 100644
--- a/p2p/base/turnport_unittest.cc
+++ b/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/p2p/client/basicportallocator.cc b/p2p/client/basicportallocator.cc
index 12d70a3..b4ec2a1 100644
--- a/p2p/client/basicportallocator.cc
+++ b/p2p/client/basicportallocator.cc
@@ -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.IsNil())
config.ports.push_back(ProtocolAddress(relay_address_udp, PROTO_UDP));
- if (!relay_address_tcp.IsAny())
+ if (!relay_address_tcp.IsNil())
config.ports.push_back(ProtocolAddress(relay_address_tcp, PROTO_TCP));
- if (!relay_address_ssl.IsAny())
+ if (!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
diff --git a/p2p/client/basicportallocator.h b/p2p/client/basicportallocator.h
index b8660f0..8a60c42 100644
--- a/p2p/client/basicportallocator.h
+++ b/p2p/client/basicportallocator.h
@@ -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
diff --git a/p2p/client/portallocator_unittest.cc b/p2p/client/portallocator_unittest.cc
index 1f027e8..44a8f27 100644
--- a/p2p/client/portallocator_unittest.cc
+++ b/p2p/client/portallocator_unittest.cc
@@ -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