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]); |