Revert "Generate localhost candidate when no STUN/TURN and portallocator has the right flag spefied."
This reverts commit 0a2955f227666efd87b2a303a69c083ef801c528. Revert "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." This reverts commit ba9ab4cd8d2e8fbc068dc36b5e6f6331d7deeccf. TBR=pthatcher@webrtc.org Review URL: https://codereview.webrtc.org/1288843003 . Cr-Commit-Position: refs/heads/master@{#9729}
This commit is contained in:
@ -223,9 +223,6 @@ class PeerConnectionInterface : public rtc::RefCountInterface {
|
||||
// TODO(pthatcher): Rename this ice_servers, but update Chromium
|
||||
// at the same time.
|
||||
IceServers servers;
|
||||
// A localhost candidate is signaled whenever a candidate with the any
|
||||
// address is allocated.
|
||||
bool enable_localhost_ice_candidate;
|
||||
BundlePolicy bundle_policy;
|
||||
RtcpMuxPolicy rtcp_mux_policy;
|
||||
TcpCandidatePolicy tcp_candidate_policy;
|
||||
@ -234,7 +231,6 @@ class PeerConnectionInterface : public rtc::RefCountInterface {
|
||||
|
||||
RTCConfiguration()
|
||||
: type(kAll),
|
||||
enable_localhost_ice_candidate(false),
|
||||
bundle_policy(kBundlePolicyBalanced),
|
||||
rtcp_mux_policy(kRtcpMuxPolicyNegotiate),
|
||||
tcp_candidate_policy(kTcpCandidatePolicyEnabled),
|
||||
|
@ -678,13 +678,6 @@ bool WebRtcSession::Initialize(
|
||||
}
|
||||
port_allocator()->set_candidate_filter(
|
||||
ConvertIceTransportTypeToCandidateFilter(rtc_configuration.type));
|
||||
|
||||
if (rtc_configuration.enable_localhost_ice_candidate) {
|
||||
port_allocator()->set_flags(
|
||||
port_allocator()->flags() |
|
||||
cricket::PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -78,8 +78,6 @@ class FakeNetworkManager : public NetworkManagerBase,
|
||||
DoUpdateNetworks();
|
||||
}
|
||||
|
||||
using NetworkManagerBase::set_enumeration_permission;
|
||||
|
||||
private:
|
||||
void DoUpdateNetworks() {
|
||||
if (!started_)
|
||||
|
@ -498,13 +498,4 @@ int IPAddressPrecedence(const IPAddress& ip) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
IPAddress GetLoopbackIP(int family) {
|
||||
if (family == AF_INET) {
|
||||
return rtc::IPAddress(INADDR_LOOPBACK);
|
||||
}
|
||||
if (family == AF_INET6) {
|
||||
return rtc::IPAddress(in6addr_loopback);
|
||||
}
|
||||
return rtc::IPAddress();
|
||||
}
|
||||
} // Namespace rtc
|
||||
} // Namespace talk base
|
||||
|
@ -179,8 +179,6 @@ int IPAddressPrecedence(const IPAddress& ip);
|
||||
// Returns 'ip' truncated to be 'length' bits long.
|
||||
IPAddress TruncateIP(const IPAddress& ip, int length);
|
||||
|
||||
IPAddress GetLoopbackIP(int family);
|
||||
|
||||
// Returns the number of contiguously set bits, counting from the MSB in network
|
||||
// byte order, in this IPAddress. Bits after the first 0 encountered are not
|
||||
// counted.
|
||||
|
@ -164,9 +164,7 @@ NetworkManager::~NetworkManager() {
|
||||
}
|
||||
|
||||
NetworkManagerBase::NetworkManagerBase()
|
||||
: enumeration_permission_(NetworkManager::kEnumerationAllowed),
|
||||
max_ipv6_networks_(kMaxIPv6Networks),
|
||||
ipv6_enabled_(true) {
|
||||
: max_ipv6_networks_(kMaxIPv6Networks), ipv6_enabled_(true) {
|
||||
}
|
||||
|
||||
NetworkManagerBase::~NetworkManagerBase() {
|
||||
@ -175,11 +173,6 @@ NetworkManagerBase::~NetworkManagerBase() {
|
||||
}
|
||||
}
|
||||
|
||||
NetworkManager::EnumerationPermission
|
||||
NetworkManagerBase::enumeration_permission() const {
|
||||
return enumeration_permission_;
|
||||
}
|
||||
|
||||
void NetworkManagerBase::GetAnyAddressNetworks(NetworkList* networks) {
|
||||
if (!ipv4_any_address_network_) {
|
||||
const rtc::IPAddress ipv4_any_address(INADDR_ANY);
|
||||
|
@ -56,16 +56,6 @@ class NetworkManager {
|
||||
public:
|
||||
typedef std::vector<Network*> NetworkList;
|
||||
|
||||
// This enum indicates whether adapter enumeration is allowed.
|
||||
enum EnumerationPermission {
|
||||
kEnumerationAllowed, // Adapter enumeration is allowed. Getting 0
|
||||
// network from GetNetworks means that there is no
|
||||
// network available.
|
||||
kEnumerationDisallowed, // Adapter enumeration is
|
||||
// disabled. GetAnyAddressNetworks() should be used
|
||||
// instead.
|
||||
};
|
||||
|
||||
NetworkManager();
|
||||
virtual ~NetworkManager();
|
||||
|
||||
@ -83,15 +73,12 @@ class NetworkManager {
|
||||
virtual void StopUpdating() = 0;
|
||||
|
||||
// Returns the current list of networks available on this machine.
|
||||
// StartUpdating() must be called before this method is called.
|
||||
// UpdateNetworks() must be called before this method is called.
|
||||
// It makes sure that repeated calls return the same object for a
|
||||
// given network, so that quality is tracked appropriately. Does not
|
||||
// include ignored networks.
|
||||
virtual void GetNetworks(NetworkList* networks) const = 0;
|
||||
|
||||
// return the current permission state of GetNetworks()
|
||||
virtual EnumerationPermission enumeration_permission() const = 0;
|
||||
|
||||
// "AnyAddressNetwork" is a network which only contains single "any address"
|
||||
// IP address. (i.e. INADDR_ANY for IPv4 or in6addr_any for IPv6). This is
|
||||
// useful as binding to such interfaces allow default routing behavior like
|
||||
@ -126,8 +113,6 @@ class NetworkManagerBase : public NetworkManager {
|
||||
void set_max_ipv6_networks(int networks) { max_ipv6_networks_ = networks; }
|
||||
int max_ipv6_networks() { return max_ipv6_networks_; }
|
||||
|
||||
EnumerationPermission enumeration_permission() const override;
|
||||
|
||||
protected:
|
||||
typedef std::map<std::string, Network*> NetworkMap;
|
||||
// Updates |networks_| with the networks listed in |list|. If
|
||||
@ -142,16 +127,10 @@ class NetworkManagerBase : public NetworkManager {
|
||||
bool* changed,
|
||||
NetworkManager::Stats* stats);
|
||||
|
||||
void set_enumeration_permission(EnumerationPermission state) {
|
||||
enumeration_permission_ = state;
|
||||
}
|
||||
|
||||
private:
|
||||
friend class NetworkTest;
|
||||
void DoUpdateNetworks();
|
||||
|
||||
EnumerationPermission enumeration_permission_;
|
||||
|
||||
NetworkList networks_;
|
||||
int max_ipv6_networks_;
|
||||
|
||||
|
@ -177,14 +177,11 @@ TEST_F(NetworkTest, DISABLED_TestCreateNetworks) {
|
||||
}
|
||||
}
|
||||
|
||||
// Test StartUpdating() and StopUpdating(). network_permission_state starts with
|
||||
// ALLOWED.
|
||||
// Test that UpdateNetworks succeeds.
|
||||
TEST_F(NetworkTest, TestUpdateNetworks) {
|
||||
BasicNetworkManager manager;
|
||||
manager.SignalNetworksChanged.connect(
|
||||
static_cast<NetworkTest*>(this), &NetworkTest::OnNetworksChanged);
|
||||
EXPECT_EQ(manager.enumeration_permission(),
|
||||
NetworkManager::kEnumerationAllowed);
|
||||
manager.StartUpdating();
|
||||
Thread::Current()->ProcessMessages(0);
|
||||
EXPECT_TRUE(callback_called_);
|
||||
@ -198,8 +195,6 @@ TEST_F(NetworkTest, TestUpdateNetworks) {
|
||||
manager.StopUpdating();
|
||||
EXPECT_TRUE(manager.started());
|
||||
manager.StopUpdating();
|
||||
EXPECT_EQ(manager.enumeration_permission(),
|
||||
NetworkManager::kEnumerationAllowed);
|
||||
EXPECT_FALSE(manager.started());
|
||||
manager.StopUpdating();
|
||||
EXPECT_FALSE(manager.started());
|
||||
|
@ -433,7 +433,7 @@ class PortTest : public testing::Test, public sigslot::has_slots<> {
|
||||
PacketSocketFactory* socket_factory) {
|
||||
UDPPort* port = UDPPort::Create(main_, socket_factory, &network_,
|
||||
addr.ipaddr(), 0, 0, username_, password_,
|
||||
std::string(), false);
|
||||
std::string());
|
||||
port->SetIceProtocolType(ice_protocol_);
|
||||
return port;
|
||||
}
|
||||
|
@ -38,7 +38,6 @@ enum {
|
||||
PORTALLOCATOR_ENABLE_SHARED_SOCKET = 0x100,
|
||||
PORTALLOCATOR_ENABLE_STUN_RETRANSMIT_ATTRIBUTE = 0x200,
|
||||
PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION = 0x400,
|
||||
PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE = 0x800,
|
||||
};
|
||||
|
||||
const uint32 kDefaultPortAllocatorFlags = 0;
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "webrtc/p2p/base/stun.h"
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/helpers.h"
|
||||
#include "webrtc/base/ipaddress.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/base/nethelpers.h"
|
||||
|
||||
@ -165,16 +164,14 @@ UDPPort::UDPPort(rtc::Thread* thread,
|
||||
rtc::AsyncPacketSocket* socket,
|
||||
const std::string& username,
|
||||
const std::string& password,
|
||||
const std::string& origin,
|
||||
bool emit_localhost_for_anyaddress)
|
||||
const std::string& origin)
|
||||
: Port(thread, factory, network, socket->GetLocalAddress().ipaddr(),
|
||||
username, password),
|
||||
requests_(thread),
|
||||
socket_(socket),
|
||||
error_(0),
|
||||
ready_(false),
|
||||
stun_keepalive_delay_(KEEPALIVE_DELAY),
|
||||
emit_localhost_for_anyaddress_(emit_localhost_for_anyaddress) {
|
||||
stun_keepalive_delay_(KEEPALIVE_DELAY) {
|
||||
requests_.set_origin(origin);
|
||||
}
|
||||
|
||||
@ -186,16 +183,14 @@ UDPPort::UDPPort(rtc::Thread* thread,
|
||||
uint16 max_port,
|
||||
const std::string& username,
|
||||
const std::string& password,
|
||||
const std::string& origin,
|
||||
bool emit_localhost_for_anyaddress)
|
||||
const std::string& origin)
|
||||
: Port(thread, LOCAL_PORT_TYPE, factory, network, ip, min_port, max_port,
|
||||
username, password),
|
||||
requests_(thread),
|
||||
socket_(NULL),
|
||||
error_(0),
|
||||
ready_(false),
|
||||
stun_keepalive_delay_(KEEPALIVE_DELAY),
|
||||
emit_localhost_for_anyaddress_(emit_localhost_for_anyaddress) {
|
||||
stun_keepalive_delay_(KEEPALIVE_DELAY) {
|
||||
requests_.set_origin(origin);
|
||||
}
|
||||
|
||||
@ -285,17 +280,9 @@ int UDPPort::GetError() {
|
||||
|
||||
void UDPPort::OnLocalAddressReady(rtc::AsyncPacketSocket* socket,
|
||||
const rtc::SocketAddress& address) {
|
||||
// When adapter enumeration is disabled and binding to the any address, the
|
||||
// loopback address will be issued as a candidate instead if
|
||||
// |emit_localhost_for_anyaddress| is true. This is to allow connectivity on
|
||||
// demo pages without STUN/TURN to work.
|
||||
rtc::SocketAddress addr = address;
|
||||
if (addr.IsAnyIP() && emit_localhost_for_anyaddress_) {
|
||||
addr.SetIP(rtc::GetLoopbackIP(addr.family()));
|
||||
}
|
||||
|
||||
AddAddress(addr, addr, rtc::SocketAddress(), UDP_PROTOCOL_NAME, "",
|
||||
LOCAL_PORT_TYPE, ICE_TYPE_PREFERENCE_HOST, 0, false);
|
||||
AddAddress(address, address, rtc::SocketAddress(),
|
||||
UDP_PROTOCOL_NAME, "", LOCAL_PORT_TYPE,
|
||||
ICE_TYPE_PREFERENCE_HOST, 0, false);
|
||||
MaybePrepareStunCandidate();
|
||||
}
|
||||
|
||||
|
@ -34,11 +34,9 @@ class UDPPort : public Port {
|
||||
rtc::AsyncPacketSocket* socket,
|
||||
const std::string& username,
|
||||
const std::string& password,
|
||||
const std::string& origin,
|
||||
bool emit_localhost_for_anyaddress) {
|
||||
const std::string& origin) {
|
||||
UDPPort* port = new UDPPort(thread, factory, network, socket,
|
||||
username, password, origin,
|
||||
emit_localhost_for_anyaddress);
|
||||
username, password, origin);
|
||||
if (!port->Init()) {
|
||||
delete port;
|
||||
port = NULL;
|
||||
@ -54,12 +52,10 @@ class UDPPort : public Port {
|
||||
uint16 max_port,
|
||||
const std::string& username,
|
||||
const std::string& password,
|
||||
const std::string& origin,
|
||||
bool emit_localhost_for_anyaddress) {
|
||||
const std::string& origin) {
|
||||
UDPPort* port = new UDPPort(thread, factory, network,
|
||||
ip, min_port, max_port,
|
||||
username, password, origin,
|
||||
emit_localhost_for_anyaddress);
|
||||
username, password, origin);
|
||||
if (!port->Init()) {
|
||||
delete port;
|
||||
port = NULL;
|
||||
@ -114,8 +110,7 @@ class UDPPort : public Port {
|
||||
uint16 max_port,
|
||||
const std::string& username,
|
||||
const std::string& password,
|
||||
const std::string& origin,
|
||||
bool emit_localhost_for_anyaddress);
|
||||
const std::string& origin);
|
||||
|
||||
UDPPort(rtc::Thread* thread,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
@ -123,8 +118,7 @@ class UDPPort : public Port {
|
||||
rtc::AsyncPacketSocket* socket,
|
||||
const std::string& username,
|
||||
const std::string& password,
|
||||
const std::string& origin,
|
||||
bool emit_localhost_for_anyaddress);
|
||||
const std::string& origin);
|
||||
|
||||
bool Init();
|
||||
|
||||
@ -208,10 +202,6 @@ class UDPPort : public Port {
|
||||
bool ready_;
|
||||
int stun_keepalive_delay_;
|
||||
|
||||
// This is true when no STUN or TURN is specified in AllocationSequence and
|
||||
// PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE is specified.
|
||||
bool emit_localhost_for_anyaddress_;
|
||||
|
||||
friend class StunBindingRequest;
|
||||
};
|
||||
|
||||
@ -255,7 +245,7 @@ class StunPort : public UDPPort {
|
||||
const ServerAddresses& servers,
|
||||
const std::string& origin)
|
||||
: UDPPort(thread, factory, network, ip, min_port, max_port, username,
|
||||
password, origin, false) {
|
||||
password, origin) {
|
||||
// UDPPort will set these to local udp, updating these to STUN.
|
||||
set_type(STUN_PORT_TYPE);
|
||||
set_server_addresses(servers);
|
||||
|
@ -82,7 +82,7 @@ class StunPortTest : public testing::Test,
|
||||
rtc::Thread::Current(), &socket_factory_,
|
||||
&network_, socket_.get(),
|
||||
rtc::CreateRandomString(16), rtc::CreateRandomString(22),
|
||||
std::string(), false));
|
||||
std::string()));
|
||||
ASSERT_TRUE(stun_port_ != NULL);
|
||||
ServerAddresses stun_servers;
|
||||
stun_servers.insert(server_addr);
|
||||
|
@ -272,7 +272,7 @@ class TurnPortTest : public testing::Test,
|
||||
udp_port_.reset(UDPPort::Create(main_, &socket_factory_, &network_,
|
||||
kLocalAddr2.ipaddr(), 0, 0,
|
||||
kIceUfrag2, kIcePwd2,
|
||||
std::string(), false));
|
||||
std::string()));
|
||||
// Set protocol type to RFC5245, as turn port is also in same mode.
|
||||
// UDP port will be controlled.
|
||||
udp_port_->SetIceProtocolType(cricket::ICEPROTO_RFC5245);
|
||||
|
@ -304,13 +304,6 @@ void BasicPortAllocatorSession::DoAllocate() {
|
||||
bool done_signal_needed = false;
|
||||
std::vector<rtc::Network*> networks;
|
||||
|
||||
// If the network permission state is BLOCKED, we just act as if the flag has
|
||||
// been passed in.
|
||||
if (allocator_->network_manager()->enumeration_permission() ==
|
||||
rtc::NetworkManager::kEnumerationDisallowed) {
|
||||
set_flags(flags() | PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION);
|
||||
}
|
||||
|
||||
// If the adapter enumeration is disabled, we'll just bind to any address
|
||||
// instead of specific NIC. This is to ensure the same routing for http
|
||||
// traffic by OS is also used here to avoid any local or public IP leakage
|
||||
@ -562,13 +555,6 @@ bool BasicPortAllocatorSession::CheckCandidateFilter(const Candidate& c) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If it's loopback address, we should allow it as it's for demo page
|
||||
// connectivity when no TURN/STUN specified.
|
||||
if (c.address().IsLoopbackIP()) {
|
||||
ASSERT((flags() & PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE) != 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
// This is just to prevent the case when binding to any address (all 0s), if
|
||||
// somehow the host candidate address is not all 0s. Either because local
|
||||
// installed proxy changes the address or a packet has been sent for any
|
||||
@ -839,19 +825,20 @@ void AllocationSequence::CreateUDPPorts() {
|
||||
// TODO(mallinath) - Remove UDPPort creating socket after shared socket
|
||||
// is enabled completely.
|
||||
UDPPort* port = NULL;
|
||||
bool emit_localhost_for_anyaddress =
|
||||
IsFlagSet(PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE);
|
||||
if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET) && udp_socket_) {
|
||||
port = UDPPort::Create(
|
||||
session_->network_thread(), session_->socket_factory(), network_,
|
||||
udp_socket_.get(), session_->username(), session_->password(),
|
||||
session_->allocator()->origin(), emit_localhost_for_anyaddress);
|
||||
port = UDPPort::Create(session_->network_thread(),
|
||||
session_->socket_factory(), network_,
|
||||
udp_socket_.get(),
|
||||
session_->username(), session_->password(),
|
||||
session_->allocator()->origin());
|
||||
} else {
|
||||
port = UDPPort::Create(
|
||||
session_->network_thread(), session_->socket_factory(), network_, ip_,
|
||||
session_->allocator()->min_port(), session_->allocator()->max_port(),
|
||||
session_->username(), session_->password(),
|
||||
session_->allocator()->origin(), emit_localhost_for_anyaddress);
|
||||
port = UDPPort::Create(session_->network_thread(),
|
||||
session_->socket_factory(),
|
||||
network_, ip_,
|
||||
session_->allocator()->min_port(),
|
||||
session_->allocator()->max_port(),
|
||||
session_->username(), session_->password(),
|
||||
session_->allocator()->origin());
|
||||
}
|
||||
|
||||
if (port) {
|
||||
|
@ -53,8 +53,7 @@ class FakePortAllocatorSession : public PortAllocatorSession {
|
||||
0,
|
||||
username(),
|
||||
password(),
|
||||
std::string(),
|
||||
false));
|
||||
std::string()));
|
||||
AddPort(port_.get());
|
||||
}
|
||||
++port_config_count_;
|
||||
|
@ -243,15 +243,11 @@ class PortAllocatorTest : public testing::Test, public sigslot::has_slots<> {
|
||||
// it should be ignore.
|
||||
void CheckDisableAdapterEnumeration(
|
||||
uint32 total_ports,
|
||||
const rtc::IPAddress& host_candidate_addr,
|
||||
const rtc::IPAddress& stun_candidate_addr,
|
||||
const rtc::IPAddress& relay_candidate_udp_transport_addr,
|
||||
const rtc::IPAddress& relay_candidate_tcp_transport_addr) {
|
||||
if (!session_) {
|
||||
EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
|
||||
}
|
||||
session_->set_flags(session_->flags() |
|
||||
cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION |
|
||||
EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
|
||||
session_->set_flags(cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION |
|
||||
cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
|
||||
cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET);
|
||||
allocator().set_allow_tcp_listen(false);
|
||||
@ -259,36 +255,28 @@ class PortAllocatorTest : public testing::Test, public sigslot::has_slots<> {
|
||||
EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout);
|
||||
|
||||
uint32 total_candidates = 0;
|
||||
if (!host_candidate_addr.IsNil()) {
|
||||
EXPECT_PRED5(CheckCandidate, candidates_[total_candidates],
|
||||
cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp",
|
||||
rtc::SocketAddress(host_candidate_addr, 0));
|
||||
++total_candidates;
|
||||
}
|
||||
if (!stun_candidate_addr.IsNil()) {
|
||||
EXPECT_PRED5(CheckCandidate, candidates_[total_candidates],
|
||||
++total_candidates;
|
||||
EXPECT_PRED5(CheckCandidate, candidates_[0],
|
||||
cricket::ICE_CANDIDATE_COMPONENT_RTP, "stun", "udp",
|
||||
rtc::SocketAddress(stun_candidate_addr, 0));
|
||||
EXPECT_EQ(rtc::EmptySocketAddressWithFamily(
|
||||
candidates_[total_candidates].address().family()),
|
||||
candidates_[total_candidates].related_address());
|
||||
++total_candidates;
|
||||
EXPECT_EQ(
|
||||
rtc::EmptySocketAddressWithFamily(candidates_[0].address().family()),
|
||||
candidates_[0].related_address());
|
||||
}
|
||||
if (!relay_candidate_udp_transport_addr.IsNil()) {
|
||||
EXPECT_PRED5(CheckCandidate, candidates_[total_candidates],
|
||||
++total_candidates;
|
||||
EXPECT_PRED5(CheckCandidate, candidates_[1],
|
||||
cricket::ICE_CANDIDATE_COMPONENT_RTP, "relay", "udp",
|
||||
rtc::SocketAddress(relay_candidate_udp_transport_addr, 0));
|
||||
EXPECT_EQ(stun_candidate_addr,
|
||||
candidates_[total_candidates].related_address().ipaddr());
|
||||
++total_candidates;
|
||||
EXPECT_EQ(stun_candidate_addr, candidates_[1].related_address().ipaddr());
|
||||
}
|
||||
if (!relay_candidate_tcp_transport_addr.IsNil()) {
|
||||
EXPECT_PRED5(CheckCandidate, candidates_[total_candidates],
|
||||
++total_candidates;
|
||||
EXPECT_PRED5(CheckCandidate, candidates_[2],
|
||||
cricket::ICE_CANDIDATE_COMPONENT_RTP, "relay", "udp",
|
||||
rtc::SocketAddress(relay_candidate_tcp_transport_addr, 0));
|
||||
EXPECT_EQ(stun_candidate_addr,
|
||||
candidates_[total_candidates].related_address().ipaddr());
|
||||
++total_candidates;
|
||||
EXPECT_EQ(stun_candidate_addr, candidates_[2].related_address().ipaddr());
|
||||
}
|
||||
|
||||
EXPECT_EQ(total_candidates, candidates_.size());
|
||||
@ -521,7 +509,7 @@ TEST_F(PortAllocatorTest, TestDisableAdapterEnumerationBehindNat) {
|
||||
AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress());
|
||||
// Expect to see 3 ports: STUN, TURN/UDP and TCP ports, and both STUN and
|
||||
// TURN/UDP candidates.
|
||||
CheckDisableAdapterEnumeration(3U, rtc::IPAddress(), kNatUdpAddr.ipaddr(),
|
||||
CheckDisableAdapterEnumeration(3U, kNatUdpAddr.ipaddr(),
|
||||
kTurnUdpExtAddr.ipaddr(), rtc::IPAddress());
|
||||
}
|
||||
|
||||
@ -535,7 +523,7 @@ TEST_F(PortAllocatorTest,
|
||||
AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress());
|
||||
// Expect to see 3 ports: STUN, TURN/UDP and TCP ports, and both STUN and
|
||||
// TURN/UDP candidates.
|
||||
CheckDisableAdapterEnumeration(3U, rtc::IPAddress(), kNatUdpAddr.ipaddr(),
|
||||
CheckDisableAdapterEnumeration(3U, kNatUdpAddr.ipaddr(),
|
||||
kTurnUdpExtAddr.ipaddr(), rtc::IPAddress());
|
||||
}
|
||||
|
||||
@ -549,7 +537,7 @@ TEST_F(PortAllocatorTest, TestDisableAdapterEnumerationBehindNatWithTcp) {
|
||||
AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr);
|
||||
// Expect to see 4 ports - STUN, TURN/UDP, TURN/TCP and TCP port. STUN,
|
||||
// TURN/UDP, and TURN/TCP candidates.
|
||||
CheckDisableAdapterEnumeration(4U, rtc::IPAddress(), kNatUdpAddr.ipaddr(),
|
||||
CheckDisableAdapterEnumeration(4U, kNatUdpAddr.ipaddr(),
|
||||
kTurnUdpExtAddr.ipaddr(),
|
||||
kTurnUdpExtAddr.ipaddr());
|
||||
}
|
||||
@ -564,7 +552,7 @@ TEST_F(PortAllocatorTest, TestDisableAdapterEnumerationWithoutNat) {
|
||||
// Expect to see 3 ports: STUN, TURN/UDP and TCP ports, but only both STUN and
|
||||
// TURN candidates. The STUN candidate should have kClientAddr as srflx
|
||||
// address, and TURN candidate with kClientAddr as the related address.
|
||||
CheckDisableAdapterEnumeration(3U, rtc::IPAddress(), kClientAddr.ipaddr(),
|
||||
CheckDisableAdapterEnumeration(3U, kClientAddr.ipaddr(),
|
||||
kTurnUdpExtAddr.ipaddr(), rtc::IPAddress());
|
||||
}
|
||||
|
||||
@ -575,22 +563,6 @@ TEST_F(PortAllocatorTest, TestDisableAdapterEnumerationWithoutNatOrServers) {
|
||||
ResetWithNoServersOrNat();
|
||||
// Expect to see 2 ports: STUN and TCP ports, but no candidate.
|
||||
CheckDisableAdapterEnumeration(2U, rtc::IPAddress(), rtc::IPAddress(),
|
||||
rtc::IPAddress(), rtc::IPAddress());
|
||||
}
|
||||
|
||||
// Test that when adapter enumeration is disabled, with
|
||||
// PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE specified, for endpoints not behind
|
||||
// a NAT, there are a localhost candidate in addition to a STUN candidate.
|
||||
TEST_F(PortAllocatorTest,
|
||||
TestDisableAdapterEnumerationWithoutNatLocalhostCandidateRequested) {
|
||||
AddInterfaceAsDefaultRoute(kClientAddr);
|
||||
ResetWithStunServerNoNat(kStunAddr);
|
||||
EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
|
||||
session_->set_flags(cricket::PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE);
|
||||
// Expect to see 2 ports: STUN and TCP ports, localhost candidate and STUN
|
||||
// candidate.
|
||||
CheckDisableAdapterEnumeration(2U, rtc::GetLoopbackIP(AF_INET),
|
||||
kClientAddr.ipaddr(), rtc::IPAddress(),
|
||||
rtc::IPAddress());
|
||||
}
|
||||
|
||||
@ -1165,32 +1137,6 @@ TEST_F(PortAllocatorTest, TestSharedSocketNoUdpAllowed) {
|
||||
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() |
|
||||
|
Reference in New Issue
Block a user