Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: webrtc/p2p/client/basicportallocator.cc

Issue 1411253008: WebRTC should generate default private address even when adapter enumeration is disabled. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: after rebase on master Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/p2p/base/stunport.cc ('k') | webrtc/p2p/client/portallocator_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 if (allocator_->proxy().type != rtc::PROXY_NONE) 429 if (allocator_->proxy().type != rtc::PROXY_NONE)
430 port->set_proxy(allocator_->user_agent(), allocator_->proxy()); 430 port->set_proxy(allocator_->user_agent(), allocator_->proxy());
431 port->set_send_retransmit_count_attribute((allocator_->flags() & 431 port->set_send_retransmit_count_attribute((allocator_->flags() &
432 PORTALLOCATOR_ENABLE_STUN_RETRANSMIT_ATTRIBUTE) != 0); 432 PORTALLOCATOR_ENABLE_STUN_RETRANSMIT_ATTRIBUTE) != 0);
433 433
434 // Push down the candidate_filter to individual port. 434 // Push down the candidate_filter to individual port.
435 uint32_t candidate_filter = allocator_->candidate_filter(); 435 uint32_t candidate_filter = allocator_->candidate_filter();
436 436
437 // When adapter enumeration is disabled, disable CF_HOST at port level so 437 // When adapter enumeration is disabled, disable CF_HOST at port level so
438 // local address is not leaked by stunport in the candidate's related address. 438 // local address is not leaked by stunport in the candidate's related address.
439 if (flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION) { 439 if ((flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION) &&
440 (flags() & PORTALLOCATOR_DISABLE_DEFAULT_LOCAL_CANDIDATE)) {
440 candidate_filter &= ~CF_HOST; 441 candidate_filter &= ~CF_HOST;
441 } 442 }
442 port->set_candidate_filter(candidate_filter); 443 port->set_candidate_filter(candidate_filter);
443 444
444 PortData data(port, seq); 445 PortData data(port, seq);
445 ports_.push_back(data); 446 ports_.push_back(data);
446 447
447 port->SignalCandidateReady.connect( 448 port->SignalCandidateReady.connect(
448 this, &BasicPortAllocatorSession::OnCandidateReady); 449 this, &BasicPortAllocatorSession::OnCandidateReady);
449 port->SignalPortComplete.connect(this, 450 port->SignalPortComplete.connect(this,
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 if ((filter & CF_REFLEXIVE) && !c.address().IsPrivateIP()) { 594 if ((filter & CF_REFLEXIVE) && !c.address().IsPrivateIP()) {
594 // We allow host candidates if the filter allows server-reflexive 595 // We allow host candidates if the filter allows server-reflexive
595 // candidates and the candidate is a public IP. Because we don't generate 596 // candidates and the candidate is a public IP. Because we don't generate
596 // server-reflexive candidates if they have the same IP as the host 597 // server-reflexive candidates if they have the same IP as the host
597 // candidate (i.e. when the host candidate is a public IP), filtering to 598 // candidate (i.e. when the host candidate is a public IP), filtering to
598 // only server-reflexive candidates won't work right when the host 599 // only server-reflexive candidates won't work right when the host
599 // candidates have public IPs. 600 // candidates have public IPs.
600 return true; 601 return true;
601 } 602 }
602 603
603 // If PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE is specified and it's
604 // loopback address, we should allow it as it's for demo page connectivity
605 // when no TURN/STUN specified.
606 if (c.address().IsLoopbackIP() &&
607 (flags() & PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE) != 0) {
608 return true;
609 }
610
611 // This is just to prevent the case when binding to any address (all 0s), if
612 // somehow the host candidate address is not all 0s. Either because local
613 // installed proxy changes the address or a packet has been sent for any
614 // reason before getsockname is called.
615 if (flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION) {
616 LOG(LS_WARNING) << "Received non-0 host address: "
617 << c.address().ToString()
618 << " when adapter enumeration is disabled";
619 return false;
620 }
621
622 return ((filter & CF_HOST) != 0); 604 return ((filter & CF_HOST) != 0);
623 } 605 }
624 return false; 606 return false;
625 } 607 }
626 608
627 void BasicPortAllocatorSession::OnPortAllocationComplete( 609 void BasicPortAllocatorSession::OnPortAllocationComplete(
628 AllocationSequence* seq) { 610 AllocationSequence* seq) {
629 // Send candidate allocation complete signal if all ports are done. 611 // Send candidate allocation complete signal if all ports are done.
630 MaybeSignalCandidatesAllocationDone(); 612 MaybeSignalCandidatesAllocationDone();
631 } 613 }
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 857
876 void AllocationSequence::CreateUDPPorts() { 858 void AllocationSequence::CreateUDPPorts() {
877 if (IsFlagSet(PORTALLOCATOR_DISABLE_UDP)) { 859 if (IsFlagSet(PORTALLOCATOR_DISABLE_UDP)) {
878 LOG(LS_VERBOSE) << "AllocationSequence: UDP ports disabled, skipping."; 860 LOG(LS_VERBOSE) << "AllocationSequence: UDP ports disabled, skipping.";
879 return; 861 return;
880 } 862 }
881 863
882 // TODO(mallinath) - Remove UDPPort creating socket after shared socket 864 // TODO(mallinath) - Remove UDPPort creating socket after shared socket
883 // is enabled completely. 865 // is enabled completely.
884 UDPPort* port = NULL; 866 UDPPort* port = NULL;
885 bool emit_localhost_for_anyaddress = 867 bool emit_local_candidate_for_anyaddress =
886 IsFlagSet(PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE); 868 !IsFlagSet(PORTALLOCATOR_DISABLE_DEFAULT_LOCAL_CANDIDATE);
887 if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET) && udp_socket_) { 869 if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET) && udp_socket_) {
888 port = UDPPort::Create( 870 port = UDPPort::Create(
889 session_->network_thread(), session_->socket_factory(), network_, 871 session_->network_thread(), session_->socket_factory(), network_,
890 udp_socket_.get(), session_->username(), session_->password(), 872 udp_socket_.get(), session_->username(), session_->password(),
891 session_->allocator()->origin(), emit_localhost_for_anyaddress); 873 session_->allocator()->origin(), emit_local_candidate_for_anyaddress);
892 } else { 874 } else {
893 port = UDPPort::Create( 875 port = UDPPort::Create(
894 session_->network_thread(), session_->socket_factory(), network_, ip_, 876 session_->network_thread(), session_->socket_factory(), network_, ip_,
895 session_->allocator()->min_port(), session_->allocator()->max_port(), 877 session_->allocator()->min_port(), session_->allocator()->max_port(),
896 session_->username(), session_->password(), 878 session_->username(), session_->password(),
897 session_->allocator()->origin(), emit_localhost_for_anyaddress); 879 session_->allocator()->origin(), emit_local_candidate_for_anyaddress);
898 } 880 }
899 881
900 if (port) { 882 if (port) {
901 // If shared socket is enabled, STUN candidate will be allocated by the 883 // If shared socket is enabled, STUN candidate will be allocated by the
902 // UDPPort. 884 // UDPPort.
903 if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET)) { 885 if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET)) {
904 udp_port_ = port; 886 udp_port_ = port;
905 port->SignalDestroyed.connect(this, &AllocationSequence::OnPortDestroyed); 887 port->SignalDestroyed.connect(this, &AllocationSequence::OnPortDestroyed);
906 888
907 // If STUN is not disabled, setting stun server address to port. 889 // If STUN is not disabled, setting stun server address to port.
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 ServerAddresses servers; 1172 ServerAddresses servers;
1191 for (size_t i = 0; i < relays.size(); ++i) { 1173 for (size_t i = 0; i < relays.size(); ++i) {
1192 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) { 1174 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) {
1193 servers.insert(relays[i].ports.front().address); 1175 servers.insert(relays[i].ports.front().address);
1194 } 1176 }
1195 } 1177 }
1196 return servers; 1178 return servers;
1197 } 1179 }
1198 1180
1199 } // namespace cricket 1181 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/base/stunport.cc ('k') | webrtc/p2p/client/portallocator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698