@@ -76,6 +76,13 @@ static const SocketAddress kCascadedPrivateAddrs[2] =
76
76
{ SocketAddress (" 192.168.10.11" , 0 ), SocketAddress (" 192.168.20.22" , 0 ) };
77
77
// The address of the public STUN server.
78
78
static const SocketAddress kStunAddr (" 99.99.99.1" , cricket::STUN_SERVER_PORT);
79
+ // The addresses for the public relay server.
80
+ static const SocketAddress kRelayUdpIntAddr (" 99.99.99.2" , 5000 );
81
+ static const SocketAddress kRelayUdpExtAddr (" 99.99.99.3" , 5001 );
82
+ static const SocketAddress kRelayTcpIntAddr (" 99.99.99.2" , 5002 );
83
+ static const SocketAddress kRelayTcpExtAddr (" 99.99.99.3" , 5003 );
84
+ static const SocketAddress kRelaySslTcpIntAddr (" 99.99.99.2" , 5004 );
85
+ static const SocketAddress kRelaySslTcpExtAddr (" 99.99.99.3" , 5005 );
79
86
// The addresses for the public turn server.
80
87
static const SocketAddress kTurnUdpIntAddr (" 99.99.99.4" ,
81
88
cricket::STUN_SERVER_PORT);
@@ -127,28 +134,6 @@ cricket::Candidate CreateUdpCandidate(const std::string& type,
127
134
return c;
128
135
}
129
136
130
- cricket::BasicPortAllocator* CreateBasicPortAllocator (
131
- rtc::NetworkManager* network_manager,
132
- const cricket::ServerAddresses& stun_servers,
133
- const rtc::SocketAddress& turn_server_udp,
134
- const rtc::SocketAddress& turn_server_tcp) {
135
- cricket::RelayServerConfig turn_server (cricket::RELAY_TURN);
136
- turn_server.credentials = kRelayCredentials ;
137
- if (!turn_server_udp.IsNil ()) {
138
- turn_server.ports .push_back (
139
- cricket::ProtocolAddress (turn_server_udp, cricket::PROTO_UDP, false ));
140
- }
141
- if (!turn_server_tcp.IsNil ()) {
142
- turn_server.ports .push_back (
143
- cricket::ProtocolAddress (turn_server_tcp, cricket::PROTO_TCP, false ));
144
- }
145
- std::vector<cricket::RelayServerConfig> turn_servers (1 , turn_server);
146
-
147
- cricket::BasicPortAllocator* allocator =
148
- new cricket::BasicPortAllocator (network_manager);
149
- allocator->SetConfiguration (stun_servers, turn_servers, 0 , false );
150
- return allocator;
151
- }
152
137
} // namespace
153
138
154
139
namespace cricket {
@@ -181,6 +166,13 @@ class P2PTransportChannelTestBase : public testing::Test,
181
166
ss_scope_(ss_.get()),
182
167
stun_server_(TestStunServer::Create(main_, kStunAddr )),
183
168
turn_server_(main_, kTurnUdpIntAddr , kTurnUdpExtAddr ),
169
+ relay_server_(main_,
170
+ kRelayUdpIntAddr ,
171
+ kRelayUdpExtAddr ,
172
+ kRelayTcpIntAddr ,
173
+ kRelayTcpExtAddr ,
174
+ kRelaySslTcpIntAddr ,
175
+ kRelaySslTcpExtAddr ),
184
176
socks_server1_(ss_.get(),
185
177
kSocksProxyAddrs[0],
186
178
ss_.get(),
@@ -193,15 +185,14 @@ class P2PTransportChannelTestBase : public testing::Test,
193
185
ep1_.role_ = ICEROLE_CONTROLLING;
194
186
ep2_.role_ = ICEROLE_CONTROLLED;
195
187
196
- turn_server_.AddInternalSocket (kTurnTcpIntAddr , PROTO_TCP);
197
188
ServerAddresses stun_servers;
198
189
stun_servers.insert (kStunAddr );
199
- ep1_.allocator_ .reset (
200
- CreateBasicPortAllocator ( &ep1_.network_manager_ , stun_servers,
201
- kTurnUdpIntAddr , kTurnTcpIntAddr ));
202
- ep2_.allocator_ .reset (
203
- CreateBasicPortAllocator ( &ep2_.network_manager_ , stun_servers,
204
- kTurnUdpIntAddr , kTurnTcpIntAddr ));
190
+ ep1_.allocator_ .reset (new BasicPortAllocator (
191
+ &ep1_.network_manager_ , stun_servers, kRelayUdpIntAddr ,
192
+ kRelayTcpIntAddr , kRelaySslTcpIntAddr ));
193
+ ep2_.allocator_ .reset (new BasicPortAllocator (
194
+ &ep2_.network_manager_ , stun_servers, kRelayUdpIntAddr ,
195
+ kRelayTcpIntAddr , kRelaySslTcpIntAddr ));
205
196
}
206
197
207
198
protected:
@@ -853,6 +844,7 @@ class P2PTransportChannelTestBase : public testing::Test,
853
844
rtc::SocketServerScope ss_scope_;
854
845
std::unique_ptr<TestStunServer> stun_server_;
855
846
TestTurnServer turn_server_;
847
+ TestRelayServer relay_server_;
856
848
rtc::SocksProxyServer socks_server1_;
857
849
rtc::SocksProxyServer socks_server2_;
858
850
Endpoint ep1_;
@@ -959,6 +951,22 @@ class P2PTransportChannelTest : public P2PTransportChannelTestBase {
959
951
Config config2,
960
952
int allocator_flags1,
961
953
int allocator_flags2) {
954
+ ServerAddresses stun_servers;
955
+ stun_servers.insert (kStunAddr );
956
+ GetEndpoint (0 )->allocator_ .reset (new BasicPortAllocator (
957
+ &(GetEndpoint (0 )->network_manager_ ), stun_servers, rtc::SocketAddress (),
958
+ rtc::SocketAddress (), rtc::SocketAddress ()));
959
+ GetEndpoint (1 )->allocator_ .reset (new BasicPortAllocator (
960
+ &(GetEndpoint (1 )->network_manager_ ), stun_servers, rtc::SocketAddress (),
961
+ rtc::SocketAddress (), rtc::SocketAddress ()));
962
+
963
+ RelayServerConfig turn_server (RELAY_TURN);
964
+ turn_server.credentials = kRelayCredentials ;
965
+ turn_server.ports .push_back (
966
+ ProtocolAddress (kTurnUdpIntAddr , PROTO_UDP, false ));
967
+ GetEndpoint (0 )->allocator_ ->AddTurnServer (turn_server);
968
+ GetEndpoint (1 )->allocator_ ->AddTurnServer (turn_server);
969
+
962
970
int delay = kMinimumStepDelay ;
963
971
ConfigureEndpoint (0 , config1);
964
972
SetAllocatorFlags (0 , allocator_flags1);
@@ -3806,11 +3814,15 @@ class P2PTransportChannelMostLikelyToWorkFirstTest
3806
3814
P2PTransportChannelMostLikelyToWorkFirstTest ()
3807
3815
: turn_server_(rtc::Thread::Current(), kTurnUdpIntAddr , kTurnUdpExtAddr ) {
3808
3816
network_manager_.AddInterface (kPublicAddrs [0 ]);
3809
- allocator_.reset (
3810
- CreateBasicPortAllocator ( &network_manager_, ServerAddresses (),
3811
- kTurnUdpIntAddr , rtc::SocketAddress ()));
3817
+ allocator_.reset (new BasicPortAllocator (
3818
+ &network_manager_, ServerAddresses (), rtc::SocketAddress (),
3819
+ rtc::SocketAddress () , rtc::SocketAddress ()));
3812
3820
allocator_->set_flags (allocator_->flags () | PORTALLOCATOR_DISABLE_STUN |
3813
3821
PORTALLOCATOR_DISABLE_TCP);
3822
+ RelayServerConfig config (RELAY_TURN);
3823
+ config.credentials = kRelayCredentials ;
3824
+ config.ports .push_back (ProtocolAddress (kTurnUdpIntAddr , PROTO_UDP, false ));
3825
+ allocator_->AddTurnServer (config);
3814
3826
allocator_->set_step_delay (kMinimumStepDelay );
3815
3827
}
3816
3828
0 commit comments