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

Unified Diff: webrtc/p2p/base/p2ptransportchannel_unittest.cc

Issue 2936553003: Adding PortAllocator option to support cases where sockets can't be bound. (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/p2p/base/p2ptransportchannel_unittest.cc
diff --git a/webrtc/p2p/base/p2ptransportchannel_unittest.cc b/webrtc/p2p/base/p2ptransportchannel_unittest.cc
index 102860d5fc850d0404664c6374ab1907a038dfbf..8367f9c5bfb7dcb09519d7ba630c302dbb34b72f 100644
--- a/webrtc/p2p/base/p2ptransportchannel_unittest.cc
+++ b/webrtc/p2p/base/p2ptransportchannel_unittest.cc
@@ -1057,6 +1057,7 @@ class P2PTransportChannelTest : public P2PTransportChannelTestBase {
}
break;
default:
+ RTC_NOTREACHED();
break;
}
}
@@ -1566,6 +1567,32 @@ TEST_F(P2PTransportChannelTest, IncomingOnlyOpen) {
DestroyChannels();
}
+// Test that two peers can connect when one can only make outgoing TCP
+// connections. This has been observed in some scenarios involving
+// VPNs/firewalls.
+TEST_F(P2PTransportChannelTest, CanOnlyMakeOutgoingTcpConnections) {
+ // The PORTALLOCATOR_ENABLE_ANY_ADDRESS_PORTS flag is required if the
+ // application needs this use case to work, since the application must accept
+ // the tradeoff that more candidates need to be allocated.
+ //
+ // TODO(deadbeef): Later, make this flag the default, and do more elegant
+ // things to ensure extra candidates don't waste resources?
+ ConfigureEndpoints(
+ OPEN, OPEN,
+ kDefaultPortAllocatorFlags | PORTALLOCATOR_ENABLE_ANY_ADDRESS_PORTS,
+ kDefaultPortAllocatorFlags);
+ // In order to simulate nothing working but outgoing TCP connections, prevent
+ // the endpoint from binding to its interface's address as well as the
+ // "any" addresses. It can then only make a connection by using "Connect()".
+ fw()->SetInvalidBindIps({rtc::GetAnyIP(AF_INET), rtc::GetAnyIP(AF_INET6),
+ kPublicAddrs[0].ipaddr()});
+ CreateChannels();
+ // Expect a "prflx" candidate on the side that can only make outgoing
+ // connections, endpoint 0.
+ Test(kPrflxTcpToLocalTcp);
+ DestroyChannels();
+}
+
TEST_F(P2PTransportChannelTest, TestTcpConnectionsFromActiveToPassive) {
rtc::ScopedFakeClock clock;
AddAddress(0, kPublicAddrs[0]);

Powered by Google App Engine
This is Rietveld 408576698