Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(758)

Side by Side Diff: webrtc/p2p/base/port_unittest.cc

Issue 1215713003: Ensuring that UDP TURN servers are always used as STUN servers. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing compiler warning from size_t->int cast Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/base/socketadapters.cc ('k') | webrtc/p2p/client/basicportallocator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 29 matching lines...) Expand all
40 using rtc::NAT_SYMMETRIC; 40 using rtc::NAT_SYMMETRIC;
41 using rtc::PacketSocketFactory; 41 using rtc::PacketSocketFactory;
42 using rtc::scoped_ptr; 42 using rtc::scoped_ptr;
43 using rtc::Socket; 43 using rtc::Socket;
44 using rtc::SocketAddress; 44 using rtc::SocketAddress;
45 using namespace cricket; 45 using namespace cricket;
46 46
47 static const int kTimeout = 1000; 47 static const int kTimeout = 1000;
48 static const SocketAddress kLocalAddr1("192.168.1.2", 0); 48 static const SocketAddress kLocalAddr1("192.168.1.2", 0);
49 static const SocketAddress kLocalAddr2("192.168.1.3", 0); 49 static const SocketAddress kLocalAddr2("192.168.1.3", 0);
50 static const SocketAddress kNatAddr1("77.77.77.77", rtc::NAT_SERVER_PORT); 50 static const SocketAddress kNatAddr1("77.77.77.77", rtc::NAT_SERVER_UDP_PORT);
51 static const SocketAddress kNatAddr2("88.88.88.88", rtc::NAT_SERVER_PORT); 51 static const SocketAddress kNatAddr2("88.88.88.88", rtc::NAT_SERVER_UDP_PORT);
52 static const SocketAddress kStunAddr("99.99.99.1", STUN_SERVER_PORT); 52 static const SocketAddress kStunAddr("99.99.99.1", STUN_SERVER_PORT);
53 static const SocketAddress kRelayUdpIntAddr("99.99.99.2", 5000); 53 static const SocketAddress kRelayUdpIntAddr("99.99.99.2", 5000);
54 static const SocketAddress kRelayUdpExtAddr("99.99.99.3", 5001); 54 static const SocketAddress kRelayUdpExtAddr("99.99.99.3", 5001);
55 static const SocketAddress kRelayTcpIntAddr("99.99.99.2", 5002); 55 static const SocketAddress kRelayTcpIntAddr("99.99.99.2", 5002);
56 static const SocketAddress kRelayTcpExtAddr("99.99.99.3", 5003); 56 static const SocketAddress kRelayTcpExtAddr("99.99.99.3", 5003);
57 static const SocketAddress kRelaySslTcpIntAddr("99.99.99.2", 5004); 57 static const SocketAddress kRelaySslTcpIntAddr("99.99.99.2", 5004);
58 static const SocketAddress kRelaySslTcpExtAddr("99.99.99.3", 5005); 58 static const SocketAddress kRelaySslTcpExtAddr("99.99.99.3", 5005);
59 static const SocketAddress kTurnUdpIntAddr("99.99.99.4", STUN_SERVER_PORT); 59 static const SocketAddress kTurnUdpIntAddr("99.99.99.4", STUN_SERVER_PORT);
60 static const SocketAddress kTurnUdpExtAddr("99.99.99.5", 0); 60 static const SocketAddress kTurnUdpExtAddr("99.99.99.5", 0);
61 static const RelayCredentials kRelayCredentials("test", "test"); 61 static const RelayCredentials kRelayCredentials("test", "test");
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 336
337 class PortTest : public testing::Test, public sigslot::has_slots<> { 337 class PortTest : public testing::Test, public sigslot::has_slots<> {
338 public: 338 public:
339 PortTest() 339 PortTest()
340 : main_(rtc::Thread::Current()), 340 : main_(rtc::Thread::Current()),
341 pss_(new rtc::PhysicalSocketServer), 341 pss_(new rtc::PhysicalSocketServer),
342 ss_(new rtc::VirtualSocketServer(pss_.get())), 342 ss_(new rtc::VirtualSocketServer(pss_.get())),
343 ss_scope_(ss_.get()), 343 ss_scope_(ss_.get()),
344 network_("unittest", "unittest", rtc::IPAddress(INADDR_ANY), 32), 344 network_("unittest", "unittest", rtc::IPAddress(INADDR_ANY), 32),
345 socket_factory_(rtc::Thread::Current()), 345 socket_factory_(rtc::Thread::Current()),
346 nat_factory1_(ss_.get(), kNatAddr1), 346 nat_factory1_(ss_.get(), kNatAddr1, SocketAddress()),
347 nat_factory2_(ss_.get(), kNatAddr2), 347 nat_factory2_(ss_.get(), kNatAddr2, SocketAddress()),
348 nat_socket_factory1_(&nat_factory1_), 348 nat_socket_factory1_(&nat_factory1_),
349 nat_socket_factory2_(&nat_factory2_), 349 nat_socket_factory2_(&nat_factory2_),
350 stun_server_(TestStunServer::Create(main_, kStunAddr)), 350 stun_server_(TestStunServer::Create(main_, kStunAddr)),
351 turn_server_(main_, kTurnUdpIntAddr, kTurnUdpExtAddr), 351 turn_server_(main_, kTurnUdpIntAddr, kTurnUdpExtAddr),
352 relay_server_(main_, 352 relay_server_(main_,
353 kRelayUdpIntAddr, 353 kRelayUdpIntAddr,
354 kRelayUdpExtAddr, 354 kRelayUdpExtAddr,
355 kRelayTcpIntAddr, 355 kRelayTcpIntAddr,
356 kRelayTcpExtAddr, 356 kRelayTcpExtAddr,
357 kRelaySslTcpIntAddr, 357 kRelaySslTcpIntAddr,
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 RelayPort* port = RelayPort::Create(main_, &socket_factory_, &network_, 500 RelayPort* port = RelayPort::Create(main_, &socket_factory_, &network_,
501 addr.ipaddr(), 0, 0, 501 addr.ipaddr(), 0, 0,
502 username_, password_); 502 username_, password_);
503 // TODO: Add an external address for ext_proto, so that the 503 // TODO: Add an external address for ext_proto, so that the
504 // other side can connect to this port using a non-UDP protocol. 504 // other side can connect to this port using a non-UDP protocol.
505 port->SetIceProtocolType(ice_protocol_); 505 port->SetIceProtocolType(ice_protocol_);
506 return port; 506 return port;
507 } 507 }
508 rtc::NATServer* CreateNatServer(const SocketAddress& addr, 508 rtc::NATServer* CreateNatServer(const SocketAddress& addr,
509 rtc::NATType type) { 509 rtc::NATType type) {
510 return new rtc::NATServer(type, ss_.get(), addr, ss_.get(), addr); 510 return new rtc::NATServer(type, ss_.get(), addr, addr, ss_.get(), addr);
511 } 511 }
512 static const char* StunName(NATType type) { 512 static const char* StunName(NATType type) {
513 switch (type) { 513 switch (type) {
514 case NAT_OPEN_CONE: return "stun(open cone)"; 514 case NAT_OPEN_CONE: return "stun(open cone)";
515 case NAT_ADDR_RESTRICTED: return "stun(addr restricted)"; 515 case NAT_ADDR_RESTRICTED: return "stun(addr restricted)";
516 case NAT_PORT_RESTRICTED: return "stun(port restricted)"; 516 case NAT_PORT_RESTRICTED: return "stun(port restricted)";
517 case NAT_SYMMETRIC: return "stun(symmetric)"; 517 case NAT_SYMMETRIC: return "stun(symmetric)";
518 default: return "stun(?)"; 518 default: return "stun(?)";
519 } 519 }
520 } 520 }
(...skipping 2075 matching lines...) Expand 10 before | Expand all | Expand 10 after
2596 // Set up channels and ensure both ports will be deleted. 2596 // Set up channels and ensure both ports will be deleted.
2597 TestChannel ch1(port1, port2); 2597 TestChannel ch1(port1, port2);
2598 TestChannel ch2(port2, port1); 2598 TestChannel ch2(port2, port1);
2599 2599
2600 // Simulate a connection that succeeds, and then is destroyed. 2600 // Simulate a connection that succeeds, and then is destroyed.
2601 StartConnectAndStopChannels(&ch1, &ch2); 2601 StartConnectAndStopChannels(&ch1, &ch2);
2602 2602
2603 // The controlled port should be destroyed after 10 milliseconds. 2603 // The controlled port should be destroyed after 10 milliseconds.
2604 EXPECT_TRUE_WAIT(destroyed(), kTimeout); 2604 EXPECT_TRUE_WAIT(destroyed(), kTimeout);
2605 } 2605 }
OLDNEW
« no previous file with comments | « webrtc/base/socketadapters.cc ('k') | webrtc/p2p/client/basicportallocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698