Bug 1297416 - Part 1: Split out the hiding of host candidates, and default route mode. draft
authorByron Campen [:bwc] <docfaraday@gmail.com>
Mon, 25 Jul 2016 15:47:52 -0500
changeset 411738 9238a7db6ceebc392dcc4c0fe10cfb444a1f3baa
parent 411657 938ce16be25f9c551c19ef8938e8717ed3d41ff5
child 411739 f7c723ac0fa54144631b3eca974daf9cbe561e12
push id28972
push userbcampen@mozilla.com
push dateThu, 08 Sep 2016 16:00:01 +0000
bugs1297416
milestone51.0a1
Bug 1297416 - Part 1: Split out the hiding of host candidates, and default route mode. MozReview-Commit-ID: IQtwAG35CM3
media/mtransport/nricectx.cpp
media/mtransport/nricectx.h
media/mtransport/test/ice_unittest.cpp
media/mtransport/third_party/nICEr/src/ice/ice_candidate.c
media/mtransport/third_party/nICEr/src/ice/ice_component.c
media/mtransport/third_party/nICEr/src/ice/ice_ctx.c
media/mtransport/third_party/nICEr/src/ice/ice_ctx.h
media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp
modules/libpref/init/all.js
--- a/media/mtransport/nricectx.cpp
+++ b/media/mtransport/nricectx.cpp
@@ -532,18 +532,28 @@ NrIceCtx::Initialize(bool hide_non_defau
   }
 
   // Create the ICE context
   int r;
 
   UINT4 flags = offerer_ ? NR_ICE_CTX_FLAGS_OFFERER:
       NR_ICE_CTX_FLAGS_ANSWERER;
   flags |= NR_ICE_CTX_FLAGS_AGGRESSIVE_NOMINATION;
-  if (policy_ == ICE_POLICY_RELAY) {
-    flags |= NR_ICE_CTX_FLAGS_RELAY_ONLY;
+  switch (policy_) {
+    case ICE_POLICY_NONE:
+      MOZ_CRASH();
+      break;
+    case ICE_POLICY_RELAY:
+      flags |= NR_ICE_CTX_FLAGS_RELAY_ONLY;
+      break;
+    case ICE_POLICY_NO_HOST:
+      flags |= NR_ICE_CTX_FLAGS_HIDE_HOST_CANDIDATES;
+      break;
+    case ICE_POLICY_ALL:
+      break;
   }
 
   if (hide_non_default)
     flags |= NR_ICE_CTX_FLAGS_ONLY_DEFAULT_ADDRS;
 
   r = nr_ice_ctx_create_with_credentials(const_cast<char *>(name_.c_str()),
                                          flags,
                                          const_cast<char *>(ufrag.c_str()),
--- a/media/mtransport/nricectx.h
+++ b/media/mtransport/nricectx.h
@@ -206,16 +206,17 @@ class NrIceCtx {
   };
 
   enum Controlling { ICE_CONTROLLING,
                      ICE_CONTROLLED
   };
 
   enum Policy { ICE_POLICY_NONE,
                 ICE_POLICY_RELAY,
+                ICE_POLICY_NO_HOST,
                 ICE_POLICY_ALL
   };
 
   // initialize ICE globals, crypto, and logging
   static void InitializeGlobals(bool allow_loopback = false,
                                 bool tcp_enabled = true,
                                 bool allow_link_local = false);
   static std::string GetNewUfrag();
--- a/media/mtransport/test/ice_unittest.cpp
+++ b/media/mtransport/test/ice_unittest.cpp
@@ -180,17 +180,16 @@ public:
 enum TrickleMode { TRICKLE_NONE, TRICKLE_SIMULATE, TRICKLE_REAL };
 
 enum ConsentStatus { CONSENT_FRESH, CONSENT_STALE, CONSENT_EXPIRED};
 
 const unsigned int ICE_TEST_PEER_OFFERER = (1 << 0);
 const unsigned int ICE_TEST_PEER_ALLOW_LOOPBACK = (1 << 1);
 const unsigned int ICE_TEST_PEER_ENABLED_TCP = (1 << 2);
 const unsigned int ICE_TEST_PEER_ALLOW_LINK_LOCAL = (1 << 3);
-const unsigned int ICE_TEST_PEER_HIDE_NON_DEFAULT = (1 << 4);
 
 typedef std::string (*CandidateFilter)(const std::string& candidate);
 
 std::vector<std::string> split(const std::string &s, char delim) {
   std::vector<std::string> elems;
   std::stringstream ss(s);
   std::string item;
   while (std::getline(ss, item, delim)) {
@@ -379,21 +378,22 @@ class SchedulableTrickleCandidate {
 
 class IceTestPeer : public sigslot::has_slots<> {
  public:
   // TODO(ekr@rtfm.com): Convert to flags when NrIceCtx::Create() does.
   // Bug 1193437.
   IceTestPeer(const std::string& name, MtransportTestUtils* utils,
               bool offerer,
               bool allow_loopback = false, bool enable_tcp = true,
-              bool allow_link_local = false, bool hide_non_default = false) :
+              bool allow_link_local = false,
+              NrIceCtx::Policy ice_policy = NrIceCtx::ICE_POLICY_ALL) :
       name_(name),
       ice_ctx_(NrIceCtxHandler::Create(name, offerer, allow_loopback,
                                        enable_tcp, allow_link_local,
-                                       hide_non_default)),
+                                       ice_policy)),
       candidates_(),
       shutting_down_(false),
       gathering_complete_(false),
       ready_ct_(0),
       ice_complete_(false),
       ice_reached_checking_(false),
       received_(0),
       sent_(0),
@@ -528,21 +528,24 @@ class IceTestPeer : public sigslot::has_
   }
 
   void SetDNSResolver() {
     ASSERT_TRUE(NS_SUCCEEDED(dns_resolver_->Init()));
     ASSERT_TRUE(NS_SUCCEEDED(ice_ctx_->ctx()->SetResolver(
         dns_resolver_->AllocateResolver())));
   }
 
-  void Gather() {
+  void Gather(bool default_route_only = false) {
     nsresult res;
 
     test_utils_->sts_target()->Dispatch(
-        WrapRunnableRet(&res, ice_ctx_->ctx(), &NrIceCtx::StartGathering),
+        WrapRunnableRet(&res,
+                        ice_ctx_->ctx(),
+                        &NrIceCtx::StartGathering,
+                        default_route_only),
         NS_DISPATCH_SYNC);
 
     ASSERT_TRUE(NS_SUCCEEDED(res));
   }
 
   void UseNat() {
     nat_->enabled_ = true;
   }
@@ -1457,18 +1460,17 @@ class WebRtcIceGatherTest : public StunT
   }
 
   void EnsurePeer(const unsigned int flags = ICE_TEST_PEER_OFFERER) {
     if (!peer_) {
       peer_ = MakeUnique<IceTestPeer>("P1", test_utils_,
                                       flags & ICE_TEST_PEER_OFFERER,
                                       flags & ICE_TEST_PEER_ALLOW_LOOPBACK,
                                       flags & ICE_TEST_PEER_ENABLED_TCP,
-                                      flags & ICE_TEST_PEER_ALLOW_LINK_LOCAL,
-                                      flags & ICE_TEST_PEER_HIDE_NON_DEFAULT);
+                                      flags & ICE_TEST_PEER_ALLOW_LINK_LOCAL);
       peer_->AddStream(1);
     }
   }
 
   void Gather(unsigned int waitTime = kDefaultTimeout) {
     EnsurePeer();
     peer_->Gather();
 
@@ -1632,26 +1634,26 @@ class WebRtcIceConnectTest : public Stun
 
   void RemoveStream(size_t index) {
     p1_->RemoveStream(index);
     p2_->RemoveStream(index);
   }
 
   void Init(bool allow_loopback,
             bool enable_tcp,
-            bool default_only = false,
-            bool setup_stun_servers = true) {
+            bool setup_stun_servers = true,
+            NrIceCtx::Policy ice_policy = NrIceCtx::ICE_POLICY_ALL) {
     if (initted_) {
       return;
     }
 
     p1_ = MakeUnique<IceTestPeer>("P1", test_utils_, true, allow_loopback,
-                                  enable_tcp, false, default_only);
+                                  enable_tcp, false, ice_policy);
     p2_ = MakeUnique<IceTestPeer>("P2", test_utils_, false, allow_loopback,
-                                  enable_tcp, false, default_only);
+                                  enable_tcp, false, ice_policy);
     InitPeer(p1_.get(), setup_stun_servers);
     InitPeer(p2_.get(), setup_stun_servers);
 
     initted_ = true;
   }
 
   void InitPeer(IceTestPeer* peer, bool setup_stun_servers = true) {
     if (use_nat_) {
@@ -1674,27 +1676,32 @@ class WebRtcIceConnectTest : public Stun
                                                       kDefaultStunServerPort, kNrIceTransportUdp));
       stun_servers.push_back(*NrIceStunServer::Create(stun_server_address_,
                                                       kDefaultStunServerPort, kNrIceTransportTcp));
 
       peer->SetStunServers(stun_servers);
     }
   }
 
-  bool Gather(unsigned int waitTime = kDefaultTimeout) {
+  bool Gather(unsigned int waitTime = kDefaultTimeout,
+              bool default_route_only = false) {
     Init(false, false);
 
-    return GatherCallerAndCallee(p1_.get(), p2_.get(), waitTime);
+    return GatherCallerAndCallee(p1_.get(),
+                                 p2_.get(),
+                                 waitTime,
+                                 default_route_only);
   }
 
   bool GatherCallerAndCallee(IceTestPeer* caller,
                              IceTestPeer* callee,
-                             unsigned int waitTime = kDefaultTimeout) {
-    caller->Gather();
-    callee->Gather();
+                             unsigned int waitTime = kDefaultTimeout,
+                             bool default_route_only = false) {
+    caller->Gather(default_route_only);
+    callee->Gather(default_route_only);
 
     if (waitTime) {
       EXPECT_TRUE_WAIT(caller->gathering_complete(), waitTime);
       if (!caller->gathering_complete())
         return false;
       EXPECT_TRUE_WAIT(callee->gathering_complete(), waitTime);
       if (!callee->gathering_complete())
         return false;
@@ -2139,22 +2146,22 @@ TEST_F(WebRtcIceGatherTest, TestGatherFa
   }
 
   EnsurePeer();
   peer_->SetStunServer(stun_server_address_, kDefaultStunServerPort);
   peer_->SetFakeResolver(stun_server_address_, stun_server_hostname_);
   Gather();
 }
 
-TEST_F(WebRtcIceGatherTest, TestGatherStunServerIpAddressDefaultRouteOnly) {
+TEST_F(WebRtcIceGatherTest, TestGatherStunServerIpAddressNoHost) {
   if (stun_server_address_.empty()) {
     return;
   }
 
-  peer_ = MakeUnique<IceTestPeer>("P1", test_utils_, true, false, false, false, true);
+  peer_ = MakeUnique<IceTestPeer>("P1", test_utils_, true, false, false, false, NrIceCtx::ICE_POLICY_NO_HOST);
   peer_->AddStream(1);
   peer_->SetStunServer(stun_server_address_, kDefaultStunServerPort);
   peer_->SetFakeResolver(stun_server_address_, stun_server_hostname_);
   Gather();
   ASSERT_FALSE(StreamHasMatchingCandidate(0, " host "));
 }
 
 TEST_F(WebRtcIceGatherTest, TestGatherFakeStunServerHostname) {
@@ -2441,38 +2448,36 @@ TEST_F(WebRtcIceGatherTest, TestStunServ
   UseFakeStunUdpServerWithResponse("192.0.2.1", 3333);
   TestStunServer::GetInstance(AF_INET)->SetDropInitialPackets(3);
   Gather(0);
   ASSERT_FALSE(StreamHasMatchingCandidate(0, "192.0.2.1"));
   WaitForGather();
   ASSERT_TRUE(StreamHasMatchingCandidate(0, "192.0.2.1"));
 }
 
-// Test default route only with our fake STUN server and
-// apparently NATted.
-TEST_F(WebRtcIceGatherTest, TestFakeStunServerNatedDefaultRouteOnly) {
-  peer_ = MakeUnique<IceTestPeer>("P1", test_utils_, true, false, false, false, true);
+// Test no host with our fake STUN server and apparently NATted.
+TEST_F(WebRtcIceGatherTest, TestFakeStunServerNatedNoHost) {
+  peer_ = MakeUnique<IceTestPeer>("P1", test_utils_, true, false, false, false, NrIceCtx::ICE_POLICY_NO_HOST);
   peer_->AddStream(1);
   UseFakeStunUdpServerWithResponse("192.0.2.1", 3333);
   Gather(0);
   WaitForGather();
   DumpCandidates(0);
   ASSERT_FALSE(StreamHasMatchingCandidate(0, "host"));
   ASSERT_TRUE(StreamHasMatchingCandidate(0, "srflx"));
   NrIceCandidate default_candidate;
   nsresult rv = peer_->GetDefaultCandidate(0, &default_candidate);
   if (NS_SUCCEEDED(rv)) {
     ASSERT_NE(NrIceCandidate::ICE_HOST, default_candidate.type);
   }
 }
 
-// Test default route only with our fake STUN server and
-// apparently non-NATted.
-TEST_F(WebRtcIceGatherTest, TestFakeStunServerNoNatDefaultRouteOnly) {
-  peer_ = MakeUnique<IceTestPeer>("P1", test_utils_, true, false, false, false, true);
+// Test no host with our fake STUN server and apparently non-NATted.
+TEST_F(WebRtcIceGatherTest, TestFakeStunServerNoNatNoHost) {
+  peer_ = MakeUnique<IceTestPeer>("P1", test_utils_, true, false, false, false, NrIceCtx::ICE_POLICY_NO_HOST);
   peer_->AddStream(1);
   UseTestStunServer();
   Gather(0);
   WaitForGather();
   DumpCandidates(0);
   ASSERT_FALSE(StreamHasMatchingCandidate(0, "host"));
   ASSERT_TRUE(StreamHasMatchingCandidate(0, "srflx"));
 }
@@ -2553,18 +2558,17 @@ TEST_F(WebRtcIceConnectTest, TestConnect
 
   p2_->RestartIce();
   ASSERT_FALSE(p2_->gathering_complete());
 
   // verify p1 and p2 streams are still connected after restarting ice on p2
   SendReceive(p1_.get(), p2_.get());
 
   mozilla::UniquePtr<IceTestPeer> p3_;
-  p3_ = MakeUnique<IceTestPeer>("P3", test_utils_, true, false,
-                                false, false, false);
+  p3_ = MakeUnique<IceTestPeer>("P3", test_utils_, true, false, false, false);
   InitPeer(p3_.get());
   p3_->AddStream(1);
 
   p2_->AddStream(1);
   ASSERT_TRUE(GatherCallerAndCallee(p2_.get(), p3_.get()));
   std::cout << "-------------------------------------------------" << std::endl;
   ConnectCallerAndCallee(p3_.get(), p2_.get());
   SendReceive(p1_.get(), p2_.get()); // p1 and p2 still connected
@@ -2586,18 +2590,17 @@ TEST_F(WebRtcIceConnectTest, TestConnect
 
   p2_->RestartIce();
   ASSERT_FALSE(p2_->gathering_complete());
 
   // verify p1 and p2 streams are still connected after restarting ice on p2
   SendReceive(p1_.get(), p2_.get());
 
   mozilla::UniquePtr<IceTestPeer> p3_;
-  p3_ = MakeUnique<IceTestPeer>("P3", test_utils_, true, false,
-                                false, false, false);
+  p3_ = MakeUnique<IceTestPeer>("P3", test_utils_, true, false, false, false);
   InitPeer(p3_.get());
   p3_->AddStream(1);
 
   p2_->AddStream(1);
   ASSERT_TRUE(GatherCallerAndCallee(p2_.get(), p3_.get()));
   std::cout << "-------------------------------------------------" << std::endl;
   ConnectCallerAndCallee(p3_.get(), p2_.get());
   SendReceive(p1_.get(), p2_.get()); // p1 and p2 still connected
@@ -2628,18 +2631,17 @@ TEST_F(WebRtcIceConnectTest, TestConnect
   // ICE restart should allow us to set control role again
   p2_->SetControlling(NrIceCtx::ICE_CONTROLLED);
   ASSERT_EQ(NrIceCtx::ICE_CONTROLLED, p2_->GetControlling());
   // But still only allowed to set control role once
   p2_->SetControlling(NrIceCtx::ICE_CONTROLLING);
   ASSERT_EQ(NrIceCtx::ICE_CONTROLLED, p2_->GetControlling());
 
   mozilla::UniquePtr<IceTestPeer> p3_;
-  p3_ = MakeUnique<IceTestPeer>("P3", test_utils_, true, false,
-                                false, false, false);
+  p3_ = MakeUnique<IceTestPeer>("P3", test_utils_, true, false, false, false);
   InitPeer(p3_.get());
   p3_->AddStream(1);
   // Set control role for p3 accordingly (w/o role conflict)
   p3_->SetControlling(NrIceCtx::ICE_CONTROLLING);
   ASSERT_EQ(NrIceCtx::ICE_CONTROLLING, p3_->GetControlling());
 
   p2_->AddStream(1);
   ASSERT_TRUE(GatherCallerAndCallee(p2_.get(), p3_.get()));
@@ -2677,27 +2679,27 @@ TEST_F(WebRtcIceConnectTest, DISABLED_Te
   ASSERT_TRUE(Gather());
   SetCandidateFilter(IsTcpSoCandidate);
   SetExpectedTypes(NrIceCandidate::Type::ICE_HOST,
     NrIceCandidate::Type::ICE_HOST, kNrIceTransportTcp);
   Connect();
 }
 
 // Disabled because this breaks with hairpinning.
-TEST_F(WebRtcIceConnectTest, DISABLED_TestConnectDefaultRouteOnly) {
-  Init(false, false, true);
+TEST_F(WebRtcIceConnectTest, DISABLED_TestConnectNoHost) {
+  Init(false, false, false, NrIceCtx::ICE_POLICY_NO_HOST);
   AddStream(1);
   ASSERT_TRUE(Gather());
   SetExpectedTypes(NrIceCandidate::Type::ICE_SERVER_REFLEXIVE,
     NrIceCandidate::Type::ICE_SERVER_REFLEXIVE, kNrIceTransportTcp);
   Connect();
 }
 
 TEST_F(WebRtcIceConnectTest, TestLoopbackOnlySortOf) {
-  Init(true, false, false, false);
+  Init(true, false, false);
   AddStream(1);
   SetCandidateFilter(IsLoopbackCandidate);
   ASSERT_TRUE(Gather());
   SetExpectedRemoteCandidateAddr("127.0.0.1");
   Connect();
 }
 
 TEST_F(WebRtcIceConnectTest, TestConnectBothControllingP1Wins) {
@@ -2784,33 +2786,34 @@ TEST_F(WebRtcIceConnectTest, TestConnect
   UseNat();
   AddStream(1);
   SetExpectedTypes(NrIceCandidate::Type::ICE_SERVER_REFLEXIVE,
                    NrIceCandidate::Type::ICE_SERVER_REFLEXIVE);
   ASSERT_TRUE(Gather());
   Connect();
 }
 
-TEST_F(WebRtcIceConnectTest, TestConnectNoNatRouteOnly) {
-  Init(false, false, true, false);
+TEST_F(WebRtcIceConnectTest, TestConnectNoNatNoHost) {
+  Init(false, false, false, NrIceCtx::ICE_POLICY_NO_HOST);
   AddStream(1);
   UseTestStunServer();
   // Because we are connecting from our host candidate to the
   // other side's apparent srflx (which is also their host)
   // we see a host/srflx pair.
   SetExpectedTypes(NrIceCandidate::Type::ICE_HOST,
                    NrIceCandidate::Type::ICE_SERVER_REFLEXIVE);
   ASSERT_TRUE(Gather());
   Connect();
 }
 
-TEST_F(WebRtcIceConnectTest, TestConnectFullConeDefaultRouteOnly) {
+TEST_F(WebRtcIceConnectTest, TestConnectFullConeNoHost) {
   UseNat();
-  Init(false, false, true);
+  Init(false, false, false, NrIceCtx::ICE_POLICY_NO_HOST);
   AddStream(1);
+  UseTestStunServer();
   SetExpectedTypes(NrIceCandidate::Type::ICE_SERVER_REFLEXIVE,
                    NrIceCandidate::Type::ICE_SERVER_REFLEXIVE);
   ASSERT_TRUE(Gather());
   Connect();
 }
 
 TEST_F(WebRtcIceConnectTest, TestGatherAddressRestrictedCone) {
   UseNat();
@@ -3522,17 +3525,17 @@ TEST_F(WebRtcIceConnectTest, TestPollCan
   ASSERT_NE(0U, pairs.size());
   ASSERT_TRUE(p2_->CandidatePairsPriorityDescending(pairs));
   ASSERT_TRUE(ContainsSucceededPair(pairs));
 }
 
 // TODO Bug 1259842 - disabled until we find a better way to handle two
 // candidates from different RFC1918 ranges
 TEST_F(WebRtcIceConnectTest, DISABLED_TestHostCandPairingFilter) {
-  Init(false, false, false, false);
+  Init(false, false, false);
   AddStream(1);
   ASSERT_TRUE(Gather());
   SetCandidateFilter(IsIpv4Candidate);
 
   int host_net = p1_->GetCandidatesPrivateIpv4Range(0);
   if (host_net <= 0) {
     // TODO bug 1226838: make this work with multiple private IPs
     FAIL() << "This test needs exactly one private IPv4 host candidate to work" << std::endl;
@@ -3556,17 +3559,17 @@ TEST_F(WebRtcIceConnectTest, DISABLED_Te
 }
 
 // TODO Bug 1226838 - See Comment 2 - this test can't work as written
 TEST_F(WebRtcIceConnectTest, DISABLED_TestSrflxCandPairingFilter) {
   if (stun_server_address_.empty()) {
     return;
   }
 
-  Init(false, false, false, false);
+  Init(false, false, false);
   AddStream(1);
   ASSERT_TRUE(Gather());
   SetCandidateFilter(IsSrflxCandidate);
 
   if (p1_->GetCandidatesPrivateIpv4Range(0) <= 0) {
     // TODO bug 1226838: make this work with public IP addresses
     std::cerr << "Don't run this test at IETF meetings!" << std::endl;
     FAIL() << "This test needs one private IPv4 host candidate to work" << std::endl;
--- a/media/mtransport/third_party/nICEr/src/ice/ice_candidate.c
+++ b/media/mtransport/third_party/nICEr/src/ice/ice_candidate.c
@@ -931,17 +931,17 @@ int nr_ice_format_candidate_attribute(nr
       cand->foundation, cand->component_id, cand->addr.protocol==IPPROTO_UDP?"UDP":"TCP",cand->priority, addr, port,
       nr_ctype_name(cand->type));
 
     len=strlen(attr); attr+=len; maxlen-=len;
 
     /* raddr, rport */
     raddr = (cand->stream->ctx->flags &
              (NR_ICE_CTX_FLAGS_RELAY_ONLY |
-              NR_ICE_CTX_FLAGS_ONLY_DEFAULT_ADDRS)) ?
+              NR_ICE_CTX_FLAGS_HIDE_HOST_CANDIDATES)) ?
       &cand->addr : &cand->base;
 
     switch(cand->type){
       case HOST:
         break;
       case SERVER_REFLEXIVE:
       case PEER_REFLEXIVE:
         if(r=nr_transport_addr_get_addrstring(raddr,addr,sizeof(addr)))
--- a/media/mtransport/third_party/nICEr/src/ice/ice_component.c
+++ b/media/mtransport/third_party/nICEr/src/ice/ice_component.c
@@ -688,17 +688,17 @@ int nr_ice_component_maybe_prune_candida
     c2 = TAILQ_FIRST(&comp->candidates);
     while(c2){
       if((c1 != c2) &&
          (c2->state == NR_ICE_CAND_STATE_INITIALIZED) &&
          !nr_transport_addr_cmp(&c1->base,&c2->base,NR_TRANSPORT_ADDR_CMP_MODE_ALL) &&
          !nr_transport_addr_cmp(&c1->addr,&c2->addr,NR_TRANSPORT_ADDR_CMP_MODE_ALL)){
 
         if((c1->type == c2->type) ||
-           (!(ctx->flags & NR_ICE_CTX_FLAGS_ONLY_DEFAULT_ADDRS) &&
+           (!(ctx->flags & NR_ICE_CTX_FLAGS_HIDE_HOST_CANDIDATES) &&
             ((c1->type==HOST && c2->type == SERVER_REFLEXIVE) ||
              (c2->type==HOST && c1->type == SERVER_REFLEXIVE)))){
 
           /*
              These are redundant. Remove the lower pri one, or if pairing has
              already occurred, remove the newest one.
 
              Since this algorithmis run whenever a new candidate
--- a/media/mtransport/third_party/nICEr/src/ice/ice_ctx.c
+++ b/media/mtransport/third_party/nICEr/src/ice/ice_ctx.c
@@ -987,17 +987,17 @@ int nr_ice_ctx_set_trickle_cb(nr_ice_ctx
 }
 
 int nr_ice_ctx_hide_candidate(nr_ice_ctx *ctx, nr_ice_candidate *cand)
   {
     if (cand->state != NR_ICE_CAND_STATE_INITIALIZED) {
       return 1;
     }
 
-    if (ctx->flags & NR_ICE_CTX_FLAGS_ONLY_DEFAULT_ADDRS) {
+    if (ctx->flags & NR_ICE_CTX_FLAGS_HIDE_HOST_CANDIDATES) {
       if (cand->type == HOST)
         return 1;
     }
 
     return 0;
   }
 
 int nr_ice_get_new_ice_ufrag(char** ufrag)
--- a/media/mtransport/third_party/nICEr/src/ice/ice_ctx.h
+++ b/media/mtransport/third_party/nICEr/src/ice/ice_ctx.h
@@ -158,17 +158,18 @@ struct nr_ice_ctx_ {
 
 int nr_ice_ctx_create(char *label, UINT4 flags, nr_ice_ctx **ctxp);
 int nr_ice_ctx_create_with_credentials(char *label, UINT4 flags, char* ufrag, char* pwd, nr_ice_ctx **ctxp);
 #define NR_ICE_CTX_FLAGS_OFFERER                           1
 #define NR_ICE_CTX_FLAGS_ANSWERER                          (1<<1)
 #define NR_ICE_CTX_FLAGS_AGGRESSIVE_NOMINATION             (1<<2)
 #define NR_ICE_CTX_FLAGS_LITE                              (1<<3)
 #define NR_ICE_CTX_FLAGS_RELAY_ONLY                        (1<<4)
-#define NR_ICE_CTX_FLAGS_ONLY_DEFAULT_ADDRS                (1<<5)
+#define NR_ICE_CTX_FLAGS_HIDE_HOST_CANDIDATES              (1<<5)
+#define NR_ICE_CTX_FLAGS_ONLY_DEFAULT_ADDRS                (1<<6)
 
 int nr_ice_ctx_destroy(nr_ice_ctx **ctxp);
 int nr_ice_gather(nr_ice_ctx *ctx, NR_async_cb done_cb, void *cb_arg);
 int nr_ice_add_candidate(nr_ice_ctx *ctx, nr_ice_candidate *cand);
 void nr_ice_gather_finished_cb(NR_SOCKET s, int h, void *cb_arg);
 int nr_ice_add_media_stream(nr_ice_ctx *ctx,char *label,int components, nr_ice_media_stream **streamp);
 int nr_ice_remove_media_stream(nr_ice_ctx *ctx,nr_ice_media_stream **streamp);
 int nr_ice_get_global_attributes(nr_ice_ctx *ctx,char ***attrsp, int *attrctp);
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
@@ -477,17 +477,21 @@ PeerConnectionConfiguration::Init(const 
   switch (aSrc.mIceTransportPolicy) {
     case dom::RTCIceTransportPolicy::None:
       setIceTransportPolicy(NrIceCtx::ICE_POLICY_NONE);
       break;
     case dom::RTCIceTransportPolicy::Relay:
       setIceTransportPolicy(NrIceCtx::ICE_POLICY_RELAY);
       break;
     case dom::RTCIceTransportPolicy::All:
-      setIceTransportPolicy(NrIceCtx::ICE_POLICY_ALL);
+      if (Preferences::GetBool("media.peerconnection.ice.no_host", false)) {
+        setIceTransportPolicy(NrIceCtx::ICE_POLICY_NO_HOST);
+      } else {
+        setIceTransportPolicy(NrIceCtx::ICE_POLICY_ALL);
+      }
       break;
     default:
       MOZ_CRASH();
   }
   return NS_OK;
 }
 
 nsresult
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp
@@ -778,19 +778,19 @@ PeerConnectionMedia::RollbackIceRestart_
 
 bool
 PeerConnectionMedia::GetPrefDefaultAddressOnly() const
 {
   ASSERT_ON_THREAD(mMainThread); // will crash on STS thread
 
 #if !defined(MOZILLA_EXTERNAL_LINKAGE)
   bool default_address_only = Preferences::GetBool(
-    "media.peerconnection.ice.default_address_only", false);
+    "media.peerconnection.ice.default_address_only", true);
 #else
-  bool default_address_only = false;
+  bool default_address_only = true;
 #endif
   return default_address_only;
 }
 
 void
 PeerConnectionMedia::ConnectSignals(NrIceCtx *aCtx, NrIceCtx *aOldCtx)
 {
   aCtx->SignalGatheringStateChange.connect(
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -466,16 +466,17 @@ pref("media.peerconnection.ice.tcp_so_so
 pref("media.peerconnection.ice.link_local", false); // Set only for testing IPV6 in networks that don't assign IPV6 addresses
 pref("media.peerconnection.ice.force_interface", ""); // Limit to only a single interface
 pref("media.peerconnection.ice.relay_only", false); // Limit candidates to TURN
 pref("media.peerconnection.use_document_iceservers", true);
 pref("media.peerconnection.identity.enabled", true);
 pref("media.peerconnection.identity.timeout", 10000);
 pref("media.peerconnection.ice.stun_client_maximum_transmits", 7);
 pref("media.peerconnection.ice.trickle_grace_period", 5000);
+pref("media.peerconnection.ice.no_host", false);
 pref("media.peerconnection.ice.default_address_only", false);
 
 // These values (aec, agc, and noice) are from media/webrtc/trunk/webrtc/common_types.h
 // kXxxUnchanged = 0, kXxxDefault = 1, and higher values are specific to each
 // setting (for Xxx = Ec, Agc, or Ns).  Defaults are all set to kXxxDefault here.
 pref("media.peerconnection.turn.disable", false);
 #if defined(MOZ_WEBRTC_HARDWARE_AEC_NS)
 pref("media.getusermedia.aec_enabled", false);