diff --git a/webrtc/p2p/client/basicportallocator.cc b/webrtc/p2p/client/basicportallocator.cc index 5c322da59e..41edd85e9e 100644 --- a/webrtc/p2p/client/basicportallocator.cc +++ b/webrtc/p2p/client/basicportallocator.cc @@ -412,11 +412,6 @@ void BasicPortAllocatorSession::DoAllocate() { break; } - // Disables phases that are not specified in this config. - if (!config || config->StunServers().empty()) { - // No STUN ports specified in this config. - sequence_flags |= PORTALLOCATOR_DISABLE_STUN; - } if (!config || config->relays.empty()) { // No relay ports specified in this config. sequence_flags |= PORTALLOCATOR_DISABLE_RELAY; @@ -980,9 +975,6 @@ void AllocationSequence::CreateStunPorts() { return; } - // If BasicPortAllocatorSession::OnAllocate left STUN ports enabled then we - // ought to have an address for them here. - ASSERT(config_ && !config_->StunServers().empty()); if (!(config_ && !config_->StunServers().empty())) { LOG(LS_WARNING) << "AllocationSequence: No STUN server configured, skipping."; diff --git a/webrtc/p2p/client/portallocator_unittest.cc b/webrtc/p2p/client/portallocator_unittest.cc index 0173261f37..148623dfb3 100644 --- a/webrtc/p2p/client/portallocator_unittest.cc +++ b/webrtc/p2p/client/portallocator_unittest.cc @@ -116,7 +116,9 @@ class PortAllocatorTest : public testing::Test, public sigslot::has_slots<> { rtc::NAT_OPEN_CONE, vss_.get(), kNatAddr, vss_.get(), kNatAddr)); ServerAddresses stun_servers; - stun_servers.insert(stun_server); + if (!stun_server.IsNil()) { + stun_servers.insert(stun_server); + } allocator_.reset(new cricket::BasicPortAllocator( &network_manager_, &nat_socket_factory_, stun_servers)); allocator().set_step_delay(cricket::kMinimumStepDelay); @@ -873,7 +875,8 @@ TEST_F(PortAllocatorTest, TestSharedSocketWithNatUsingTurn) { // 'relay' candidates. TEST_F(PortAllocatorTest, TestSharedSocketWithNatUsingTurnAsStun) { AddInterface(kClientAddr); - ResetWithNatServer(kTurnUdpIntAddr); + // Use an empty SocketAddress to add a NAT without STUN server. + ResetWithNatServer(SocketAddress()); AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); // Must set the step delay to 0 to make sure the relay allocation phase is