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

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

Issue 1275703006: Bug 4517: Enable connectivity for demo page when no STUN/TURN specifiefd. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 5 years, 4 months 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/turnport_unittest.cc ('k') | webrtc/p2p/client/fakeportallocator.h » ('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 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 if ((filter & CF_REFLEXIVE) && !c.address().IsPrivateIP()) { 548 if ((filter & CF_REFLEXIVE) && !c.address().IsPrivateIP()) {
549 // We allow host candidates if the filter allows server-reflexive 549 // We allow host candidates if the filter allows server-reflexive
550 // candidates and the candidate is a public IP. Because we don't generate 550 // candidates and the candidate is a public IP. Because we don't generate
551 // server-reflexive candidates if they have the same IP as the host 551 // server-reflexive candidates if they have the same IP as the host
552 // candidate (i.e. when the host candidate is a public IP), filtering to 552 // candidate (i.e. when the host candidate is a public IP), filtering to
553 // only server-reflexive candidates won't work right when the host 553 // only server-reflexive candidates won't work right when the host
554 // candidates have public IPs. 554 // candidates have public IPs.
555 return true; 555 return true;
556 } 556 }
557 557
558 // If PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE is specified and it's
559 // loopback address, we should allow it as it's for demo page connectivity
560 // when no TURN/STUN specified.
561 if (c.address().IsLoopbackIP() &&
562 (flags() & PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE) != 0) {
563 return true;
564 }
565
558 // This is just to prevent the case when binding to any address (all 0s), if 566 // This is just to prevent the case when binding to any address (all 0s), if
559 // somehow the host candidate address is not all 0s. Either because local 567 // somehow the host candidate address is not all 0s. Either because local
560 // installed proxy changes the address or a packet has been sent for any 568 // installed proxy changes the address or a packet has been sent for any
561 // reason before getsockname is called. 569 // reason before getsockname is called.
562 if (flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION) { 570 if (flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION) {
563 LOG(LS_WARNING) << "Received non-0 host address: " 571 LOG(LS_WARNING) << "Received non-0 host address: "
564 << c.address().ToString() 572 << c.address().ToString()
565 << " when adapter enumeration is disabled"; 573 << " when adapter enumeration is disabled";
566 return false; 574 return false;
567 } 575 }
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 826
819 void AllocationSequence::CreateUDPPorts() { 827 void AllocationSequence::CreateUDPPorts() {
820 if (IsFlagSet(PORTALLOCATOR_DISABLE_UDP)) { 828 if (IsFlagSet(PORTALLOCATOR_DISABLE_UDP)) {
821 LOG(LS_VERBOSE) << "AllocationSequence: UDP ports disabled, skipping."; 829 LOG(LS_VERBOSE) << "AllocationSequence: UDP ports disabled, skipping.";
822 return; 830 return;
823 } 831 }
824 832
825 // TODO(mallinath) - Remove UDPPort creating socket after shared socket 833 // TODO(mallinath) - Remove UDPPort creating socket after shared socket
826 // is enabled completely. 834 // is enabled completely.
827 UDPPort* port = NULL; 835 UDPPort* port = NULL;
836 bool emit_localhost_for_anyaddress =
837 IsFlagSet(PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE);
828 if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET) && udp_socket_) { 838 if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET) && udp_socket_) {
829 port = UDPPort::Create(session_->network_thread(), 839 port = UDPPort::Create(
830 session_->socket_factory(), network_, 840 session_->network_thread(), session_->socket_factory(), network_,
831 udp_socket_.get(), 841 udp_socket_.get(), session_->username(), session_->password(),
832 session_->username(), session_->password(), 842 session_->allocator()->origin(), emit_localhost_for_anyaddress);
833 session_->allocator()->origin());
834 } else { 843 } else {
835 port = UDPPort::Create(session_->network_thread(), 844 port = UDPPort::Create(
836 session_->socket_factory(), 845 session_->network_thread(), session_->socket_factory(), network_, ip_,
837 network_, ip_, 846 session_->allocator()->min_port(), session_->allocator()->max_port(),
838 session_->allocator()->min_port(), 847 session_->username(), session_->password(),
839 session_->allocator()->max_port(), 848 session_->allocator()->origin(), emit_localhost_for_anyaddress);
840 session_->username(), session_->password(),
841 session_->allocator()->origin());
842 } 849 }
843 850
844 if (port) { 851 if (port) {
845 // If shared socket is enabled, STUN candidate will be allocated by the 852 // If shared socket is enabled, STUN candidate will be allocated by the
846 // UDPPort. 853 // UDPPort.
847 if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET)) { 854 if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET)) {
848 udp_port_ = port; 855 udp_port_ = port;
849 port->SignalDestroyed.connect(this, &AllocationSequence::OnPortDestroyed); 856 port->SignalDestroyed.connect(this, &AllocationSequence::OnPortDestroyed);
850 857
851 // If STUN is not disabled, setting stun server address to port. 858 // If STUN is not disabled, setting stun server address to port.
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 ServerAddresses servers; 1134 ServerAddresses servers;
1128 for (size_t i = 0; i < relays.size(); ++i) { 1135 for (size_t i = 0; i < relays.size(); ++i) {
1129 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) { 1136 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) {
1130 servers.insert(relays[i].ports.front().address); 1137 servers.insert(relays[i].ports.front().address);
1131 } 1138 }
1132 } 1139 }
1133 return servers; 1140 return servers;
1134 } 1141 }
1135 1142
1136 } // namespace cricket 1143 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/base/turnport_unittest.cc ('k') | webrtc/p2p/client/fakeportallocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698