In the past, P2PPortAllocator.enable_multiple_routes is the indicator whether we should bind to the any address. It's easy to translate that into a port allocator flag in P2PPortAllocator's ctor. Going forward, we have to depend on an asynchronous permission check to determine whether gathering local address is allowed or not, hence the current way of passing it through constructor approach won't work any more. The asynchronous check will trigger SignalNetowrksChanged so we could only check that inside DoAllocate.
Adapter enumeration disable should be a concept from Network. Network will be hooked up with media permission (mic/camera) to check whether gathering local address is allowed.
BUG=crbug.com/520101
R=juberti@webrtc.org, pthatcher@webrtc.org
Committed: https://chromium.googlesource.com/external/webrtc/+/ba9ab4cd8d2e8fbc068dc36b5e6f6331d7deeccf
Review URL: https://codereview.webrtc.org/1284113003 .
Cr-Commit-Position: refs/heads/master@{#9735}
diff --git a/webrtc/p2p/client/portallocator_unittest.cc b/webrtc/p2p/client/portallocator_unittest.cc
index 5e2c1f8..7386143 100644
--- a/webrtc/p2p/client/portallocator_unittest.cc
+++ b/webrtc/p2p/client/portallocator_unittest.cc
@@ -1137,6 +1137,32 @@
EXPECT_EQ(1U, candidates_.size());
}
+// Test that when the NetworkManager doesn't have permission to enumerate
+// adapters, the PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION is specified
+// automatically.
+TEST_F(PortAllocatorTest, TestNetworkPermissionBlocked) {
+ AddInterface(kClientAddr);
+ network_manager_.set_enumeration_permission(
+ rtc::NetworkManager::kEnumerationDisallowed);
+ allocator().set_flags(allocator().flags() |
+ cricket::PORTALLOCATOR_DISABLE_RELAY |
+ cricket::PORTALLOCATOR_DISABLE_TCP |
+ cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
+ cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET);
+ EXPECT_EQ(
+ allocator_->flags() & cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION,
+ 0U);
+ EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
+ EXPECT_EQ(
+ session_->flags() & cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION,
+ 0U);
+ session_->StartGettingPorts();
+ EXPECT_EQ_WAIT(1U, ports_.size(), kDefaultAllocationTimeout);
+ EXPECT_EQ(0U, candidates_.size());
+ EXPECT_TRUE((session_->flags() &
+ cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION) != 0);
+}
+
// This test verifies allocator can use IPv6 addresses along with IPv4.
TEST_F(PortAllocatorTest, TestEnableIPv6Addresses) {
allocator().set_flags(allocator().flags() |