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

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

Issue 2936553003: Adding PortAllocator option to support cases where sockets can't be bound. (Closed)
Patch Set: Comment fixes Created 3 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright 2009 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2009 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 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 } else if (config == PROXY_SOCKS) { 1050 } else if (config == PROXY_SOCKS) {
1051 // Block all TCP to/from the endpoint except to the proxy server 1051 // Block all TCP to/from the endpoint except to the proxy server
1052 fw()->AddRule(true, rtc::FP_TCP, kPublicAddrs[endpoint], 1052 fw()->AddRule(true, rtc::FP_TCP, kPublicAddrs[endpoint],
1053 kSocksProxyAddrs[endpoint]); 1053 kSocksProxyAddrs[endpoint]);
1054 fw()->AddRule(false, rtc::FP_TCP, rtc::FD_ANY, 1054 fw()->AddRule(false, rtc::FP_TCP, rtc::FD_ANY,
1055 kPublicAddrs[endpoint]); 1055 kPublicAddrs[endpoint]);
1056 SetProxy(endpoint, rtc::PROXY_SOCKS5); 1056 SetProxy(endpoint, rtc::PROXY_SOCKS5);
1057 } 1057 }
1058 break; 1058 break;
1059 default: 1059 default:
1060 RTC_NOTREACHED();
1060 break; 1061 break;
1061 } 1062 }
1062 } 1063 }
1063 }; 1064 };
1064 1065
1065 // Shorthands for use in the test matrix. 1066 // Shorthands for use in the test matrix.
1066 #define LULU &kLocalUdpToLocalUdp 1067 #define LULU &kLocalUdpToLocalUdp
1067 #define LUSU &kLocalUdpToStunUdp 1068 #define LUSU &kLocalUdpToStunUdp
1068 #define LUPU &kLocalUdpToPrflxUdp 1069 #define LUPU &kLocalUdpToPrflxUdp
1069 #define PULU &kPrflxUdpToLocalUdp 1070 #define PULU &kPrflxUdpToLocalUdp
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
1559 1560
1560 EXPECT_TRUE_SIMULATED_WAIT( 1561 EXPECT_TRUE_SIMULATED_WAIT(
1561 ep1_ch1() != NULL && ep2_ch1() != NULL && ep1_ch1()->receiving() && 1562 ep1_ch1() != NULL && ep2_ch1() != NULL && ep1_ch1()->receiving() &&
1562 ep1_ch1()->writable() && ep2_ch1()->receiving() && 1563 ep1_ch1()->writable() && ep2_ch1()->receiving() &&
1563 ep2_ch1()->writable(), 1564 ep2_ch1()->writable(),
1564 kMediumTimeout, clock); 1565 kMediumTimeout, clock);
1565 1566
1566 DestroyChannels(); 1567 DestroyChannels();
1567 } 1568 }
1568 1569
1570 // Test that two peers can connect when one can only make outgoing TCP
1571 // connections. This has been observed in some scenarios involving
1572 // VPNs/firewalls.
1573 TEST_F(P2PTransportChannelTest, CanOnlyMakeOutgoingTcpConnections) {
1574 // The PORTALLOCATOR_ENABLE_ANY_ADDRESS_PORTS flag is required if the
1575 // application needs this use case to work, since the application must accept
1576 // the tradeoff that more candidates need to be allocated.
1577 //
1578 // TODO(deadbeef): Later, make this flag the default, and do more elegant
1579 // things to ensure extra candidates don't waste resources?
1580 ConfigureEndpoints(
1581 OPEN, OPEN,
1582 kDefaultPortAllocatorFlags | PORTALLOCATOR_ENABLE_ANY_ADDRESS_PORTS,
1583 kDefaultPortAllocatorFlags);
1584 // In order to simulate nothing working but outgoing TCP connections, prevent
1585 // the endpoint from binding to its interface's address as well as the
1586 // "any" addresses. It can then only make a connection by using "Connect()".
1587 fw()->SetInvalidBindIps({rtc::GetAnyIP(AF_INET), rtc::GetAnyIP(AF_INET6),
1588 kPublicAddrs[0].ipaddr()});
1589 CreateChannels();
1590 // Expect a "prflx" candidate on the side that can only make outgoing
1591 // connections, endpoint 0.
1592 Test(kPrflxTcpToLocalTcp);
1593 DestroyChannels();
1594 }
1595
1569 TEST_F(P2PTransportChannelTest, TestTcpConnectionsFromActiveToPassive) { 1596 TEST_F(P2PTransportChannelTest, TestTcpConnectionsFromActiveToPassive) {
1570 rtc::ScopedFakeClock clock; 1597 rtc::ScopedFakeClock clock;
1571 AddAddress(0, kPublicAddrs[0]); 1598 AddAddress(0, kPublicAddrs[0]);
1572 AddAddress(1, kPublicAddrs[1]); 1599 AddAddress(1, kPublicAddrs[1]);
1573 1600
1574 SetAllocationStepDelay(0, kMinimumStepDelay); 1601 SetAllocationStepDelay(0, kMinimumStepDelay);
1575 SetAllocationStepDelay(1, kMinimumStepDelay); 1602 SetAllocationStepDelay(1, kMinimumStepDelay);
1576 1603
1577 int kOnlyLocalTcpPorts = PORTALLOCATOR_DISABLE_UDP | 1604 int kOnlyLocalTcpPorts = PORTALLOCATOR_DISABLE_UDP |
1578 PORTALLOCATOR_DISABLE_STUN | 1605 PORTALLOCATOR_DISABLE_STUN |
(...skipping 2808 matching lines...) Expand 10 before | Expand all | Expand 10 after
4387 4414
4388 // TCP Relay/Relay is the next. 4415 // TCP Relay/Relay is the next.
4389 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE, 4416 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE,
4390 TCP_PROTOCOL_NAME); 4417 TCP_PROTOCOL_NAME);
4391 4418
4392 // Finally, Local/Relay will be pinged. 4419 // Finally, Local/Relay will be pinged.
4393 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE); 4420 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE);
4394 } 4421 }
4395 4422
4396 } // namespace cricket { 4423 } // namespace cricket {
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698